简体   繁体   English

Web部署项目/ MSBuild-TempBuildDir

[英]Web Deployment Project / MSBuild - TempBuildDir

When using the Web Deployment Project MSBuild uses the folder '.TempBuildDir' when performing the build. 使用Web部署项目时, MSBuild在执行构建时使用文件夹“ .TempBuildDir”。 Is it possible to specify an alternative folder? 是否可以指定备用文件夹?

In C:\\Program Files\\MSBuild\\Microsoft\\WebDeployment\\v9.0 or v10.0 directory is the Microsoft.WebDeployment.targets file where the TempBuildDir property is defined in the _PrepareForBuild target. Microsoft.WebDeployment.targets文件位于C:\\ Program Files \\ MSBuild \\ Microsoft \\ WebDeployment \\ v9.0或v10.0目录中,该文件在_PrepareForBuild目标中定义了TempBuildDir属性。

Since they use the CreateProperty task to set TempBuildDir it is always set to the hard-coded value even if the property already exists. 由于他们使用CreateProperty任务设置TempBuildDir,因此即使该属性已经存在,也始终将其设置为硬编码值。 This could be to eliminate the problem of someone using TempBuildDir property for something else and messing up the build. 这可以消除有人使用TempBuildDir属性进行其他操作并弄乱了构建的问题。

You would have to change the Microsoft.WebDeployment.targets file to use a different temp directory. 您将必须更改Microsoft.WebDeployment.targets文件以使用其他临时目录。

WARNING: The following is changing a file you don't have control over so use are your own risk. 警告:以下内容正在更改您无法控制的文件,因此使用风险自负。

If you were to change the following lines in the _PrepareForBuild target from 如果要更改_PrepareForBuild目标中的以下行,请从

  <CreateProperty Value=".\TempBuildDir\">
    <Output TaskParameter="Value" PropertyName="TempBuildDir" />
  </CreateProperty>

to

 <CreateProperty Value="$(MySpecialWebTempBuildDir)" Condition=" '$(MySpecialWebTempBuildDir)' != '' ">
    <Output TaskParameter="Value" PropertyName="TempBuildDir" />
  </CreateProperty>
  <CreateProperty Value=".\TempBuildDir\" Condition=" '$(MySpecialWebTempBuildDir)' == '' ">
    <Output TaskParameter="Value" PropertyName="TempBuildDir" />
  </CreateProperty>

Then set the MySpecialWebTempBuildDir property in your project file and it should override it. 然后在您的项目文件中设置MySpecialWebTempBuildDir属性,它应该覆盖它。 If you don't set MySpecialWebTempBuildDir then it will use TempBuildDir as before. 如果未设置MySpecialWebTempBuildDir,则它将像以前一样使用TempBuildDir。

If you install an update to the web deployment package your changes will get overwritten. 如果您将更新安装到Web部署程序包,您的更改将被覆盖。

Another solution is to uncomment and override the "BeforeBuild" target of the web deployment project as follows: 另一个解决方案是取消注释并覆盖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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM