2013-05-28 63 views
0

在VS 2012與更新2我有一個我發佈的網站。新的發佈嚮導被配置爲將站點發布到我的磁盤上的文件夾。同時檢查我的臨時文件文件夾上的東西,我跑了一個發佈我的網站。我看到的是,發佈者創建的%TEMP文件夾%\ WebSitePublish,並在那裏創建了該網站的3份:如何設置pubxml刪除臨時文件發佈後

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\ 

,因爲我的網站是巨大的(1.6GB),每個文件夾都採取1.6GB和4.8 GB總數。 雖然我認爲這是浪費磁盤空間,即使在發佈時,我也無法與MS討論他們實現發佈的方式。唯一讓我感到困擾的是,即使在關閉VS IDE之後,r:\ temp \ WebSitePublish \ web-1279598559文件夾仍然保留並仍然佔用4.8GB。如何讓發佈者在完成發佈後刪除它的臨時文件?

我對這個網站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> 
+0

這可能是一個愚蠢的問題,但爲什麼你的網站1.6GB創建的列表? – drzaus

+0

我有很多登錄屏幕用於安裝我們系統的各種品牌。每個登錄屏幕包含圖像,文件,其中一些有閃光燈。當安裝我的網站時,我有一個工具可以根據特定的安裝刪除所有不需要的登錄。這使整個站點在開發機器上達到1.6GB,在典型的生產機器上達到約70MB –

回答

1

我覺得你可以建立一個「構建目標」在你.csproj文件(?也許在.pubxml文件,而不是),像Why does MSBuild ignore my BeforePublish target?How can I prevent hidden .svn folder from being copied from the _bin_deployableAssemblies folder?@sayed-ibrahim-hashimi關於構建目標有很多答案。

在我的經驗,它已經非常棘手弄清楚什麼樣的目標,以重視,因爲出現了不同的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> 

的重要組成部分在這裏分別是:

  • AfterTargets - 指定在這個任務應該運行(與AfterPublish應該是不言自明的,我認爲這是正確的)
  • CreateItem - 掃描指定目錄水珠和列表設置爲可變@(GeneratedFiles)
  • Delete - 刪除由CreateItem