Web Deployment Project / MSBuild - TempBuildDir
When using the Web Deployment Project MSBuild uses the folder '.TempBuildDir' when performing the build. Is it possible to specify an alter开发者_Python百科native 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.
Since they use the CreateProperty task to set TempBuildDir it is always set to the hard-coded value even if the property already exists. This could be to eliminate the problem of someone using TempBuildDir property for something else and messing up the build.
You would have to change the Microsoft.WebDeployment.targets file to use a different temp directory.
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
<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. If you don't set MySpecialWebTempBuildDir then it will use TempBuildDir as before.
If you install an update to the web deployment package your changes will get overwritten.
Another solution is to uncomment and override the "BeforeBuild" target of the web deployment project as follows:
<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>
精彩评论