![](/img/trans.png)
[英]Starting a program with MSBuild/Web Deployment Project and not waiting for it
[英]Web Deployment Project / MSBuild - TempBuildDir
Microsoft.WebDeployment.targets文件位於C:\\ Program Files \\ MSBuild \\ Microsoft \\ WebDeployment \\ v9.0或v10.0目錄中,該文件在_PrepareForBuild目標中定義了TempBuildDir屬性。
由於他們使用CreateProperty任務設置TempBuildDir,因此即使該屬性已經存在,也始終將其設置為硬編碼值。 這可以消除有人使用TempBuildDir屬性進行其他操作並弄亂了構建的問題。
您將必須更改Microsoft.WebDeployment.targets文件以使用其他臨時目錄。
警告:以下內容正在更改您無法控制的文件,因此使用風險自負。
如果要更改_PrepareForBuild目標中的以下行,請從
<CreateProperty Value=".\TempBuildDir\">
<Output TaskParameter="Value" PropertyName="TempBuildDir" />
</CreateProperty>
至
<CreateProperty Value="$(MySpecialWebTempBuildDir)" Condition=" '$(MySpecialWebTempBuildDir)' != '' ">
<Output TaskParameter="Value" PropertyName="TempBuildDir" />
</CreateProperty>
<CreateProperty Value=".\TempBuildDir\" Condition=" '$(MySpecialWebTempBuildDir)' == '' ">
<Output TaskParameter="Value" PropertyName="TempBuildDir" />
</CreateProperty>
然后在您的項目文件中設置MySpecialWebTempBuildDir屬性,它應該覆蓋它。 如果未設置MySpecialWebTempBuildDir,則它將像以前一樣使用TempBuildDir。
如果您將更新安裝到Web部署程序包,您的更改將被覆蓋。
另一個解決方案是取消注釋並覆蓋Web部署項目的“ BeforeBuild”目標,如下所示:
<Target Name="BeforeBuild">
<CreateProperty Value=".\TempBuildDirDebug\" Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Output TaskParameter="Value" PropertyName="TempBuildDir" />
</CreateProperty>
<CreateProperty Value=".\TempBuildDirRelease\" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Output TaskParameter="Value" PropertyName="TempBuildDir" />
</CreateProperty>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.