Jon*_*onn 10 asp.net web-config
有没有办法在Web部署之外应用VS 2010 Web.Config转换,比如说在调试期间?能够在不同环境之间自由切换,这将给我一个很大的推动力.
Enr*_*lio 16
是的,您可以通过在项目文件TransformXml中的AfterBuild步骤期间调用MSBuild任务来显式执行Web.config转换.
这是一个例子:
<UsingTask
TaskName="TransformXml"
AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterBuild" Condition="exists('Web.$(Configuration).config')">
<!-- Generates the transformed Web.config in the intermediate directory -->
<TransformXml
Source="Web.config"
Destination="$(IntermediateOutputPath)Web.config"
Transform="Web.$(Configuration).config" />
<!-- Overwrites the original Web.config with the transformed configuration file -->
<Copy
SourceFiles="$(IntermediateOutputPath)Web.config"
DestinationFolder="$(ProjectDir)" />
</Target>
Run Code Online (Sandbox Code Playgroud)
相关资源:
| 归档时间: |
|
| 查看次数: |
4028 次 |
| 最近记录: |