If you add the following xml to the bottom of the .csproj file for your web application, you'll ensure that the config transformation occurs before every build:
<Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov10.0WebApplicationsMicrosoft.WebApplication.targets" />
<Target Name="BeforeBuild">
<TransformXml Source="Web.Base.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
</Target>
Edit: In response to your comment, you should be able to use Web.config as the source parameter in the TransformXml task (see step #2). If you only want to perform the config transform in the build script, follow these instructions:
1) Import WebApplication.targets in your build script like so:
<Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov10.0WebApplicationsMicrosoft.WebApplication.targets" />
2) Execute the TransformXml build task in your build script target:
<Target Name="MyBuildScriptTarget">
<TransformXml Source="Web.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
...other build tasks...
</Target>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…