[英]how to set pubxml to delete temp files after publish
in VS 2012 with Update 2 i have a web site which i publish. 在VS 2012 Update 2中,我有一个要发布的网站。 the new publish wizard was configured to publish the site to a folder on my disk.
新的发布向导已配置为将站点发布到磁盘上的文件夹中。 while checking something on my temp files folder i ran a publish of my site.
在检查我的临时文件文件夹中的内容时,我运行了我的网站的发布。 i saw that the publisher creates a folder on %TEMP%\\WebSitePublish and in there creates 3 copies of the site:
我看到发布者在%TEMP%\\ WebSitePublish上创建了一个文件夹,并在其中创建了该网站的3个副本:
r:\temp\WebSitePublish\web-1279598559\obj\Debug\AspnetCompileMerge\Source\
r:\temp\WebSitePublish\web-1279598559\obj\Debug\AspnetCompileMerge\TempBuildDir\
r:\temp\WebSitePublish\web-1279598559\obj\Debug\Package\
since my web site is huge (1.6GB) each of these folders take 1.6GB and 4.8 GB in total. 由于我的网站很大(1.6GB),因此这些文件夹中的每个文件夹总共占用1.6GB和4.8GB。 while i think this is wasting disk space even during a publish, i can't argue with MS about the way they implemented the publish.
尽管我认为即使在发布过程中这也浪费了磁盘空间,但我无法与MS争论他们实现发布的方式。 the only thing that does bother me is that even after closing the VS IDE, the r:\\temp\\WebSitePublish\\web-1279598559 folder remains and still occupies 4.8GB.
唯一令我困扰的是,即使在关闭VS IDE之后,r:\\ temp \\ WebSitePublish \\ web-1279598559文件夹仍然保留并且仍然占据4.8GB。 How can i make the publisher delete it's temp files after it finishes the publish?
完成发布后,如何使发布者删除其临时文件?
my pubxml for this site is this: 我对此站点的pubxml是这样的:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>x86</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>C:\PrecompiledWeb\Site</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>True</EnableUpdateable>
<DebugSymbols>True</DebugSymbols>
<WDPMergeOption>CreateSeparateAssembly</WDPMergeOption>
<UseFixedNames>True</UseFixedNames>
</PropertyGroup>
</Project>
I think you can set up a 'build target' in your .csproj
file (maybe in the .pubxml
file instead?), like Why does MSBuild ignore my BeforePublish target? 我认为您可以在
.csproj
文件中设置“构建目标”(也许是在.pubxml
文件中?),例如为什么MSBuild忽略我的BeforePublish目标? or How can I prevent hidden .svn folder from being copied from the _bin_deployableAssemblies folder? 或如何防止从_bin_deployableAssemblies文件夹复制隐藏的.svn文件夹? .
。 @sayed-ibrahim-hashimi has a lot of answers regarding build targets.
@ sayed-ibrahim-hashimi关于构建目标有很多答案。
In my experience it's been tricky to figure out what target to attach to, since there has been some churn between different Visual Studio releases, but I think you want something like: 根据我的经验,要确定要附加的目标是很棘手的,因为不同的Visual Studio版本之间存在一些冲突,但是我认为您需要这样的东西:
<!-- these are your instructions; name is arbitrary, `AfterTargets` says when -->
<Target Name="CleanTempDirectory" AfterTargets="AfterPublish">
<!-- use 'importance=high' to show in the Output window (?) -->
<Message Text="Cleaning up publish temp directories" Importance="high" />
<!-- here, specify the directory(ies) to clear; can use build event macros -->
<CreateItem Include="$(ProjectDir)App_Data\*\*">
<Output ItemName="GeneratedFiles" TaskParameter="Include" />
</CreateItem>
<Delete Files="@(GeneratedFiles)" />
</Target>
The important parts here are: 这里的重要部分是:
AfterTargets
-- specifies when this task should be run (and AfterPublish
should be self-explanatory; I think that's the right one) AfterTargets
指定何时应运行此任务( AfterPublish
应该是不言自明的;我认为这是正确的选择) CreateItem
-- scan the given directory glob and set a list to the variable @(GeneratedFiles)
CreateItem
扫描给定的目录glob并为变量@(GeneratedFiles)
设置列表 Delete
-- delete the list created by CreateItem
Delete
-删除由CreateItem
创建的列表
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.