本文介绍了应用Web部署外的Web.Config变换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有应用Web部署外的VS 2010的Web.Config转换的方式,在调试过程中说呢?这会给我很大的鼓舞,能够在不同环境之间自由切换。
Is there a way to apply VS 2010 Web.Config transformations outside of web deployment, say during debugging? It would give me a great boost to be able to freely switch between different environments.
推荐答案
是,您可以执行一个Web.config转型明确通过调用的TransformXML
期间在项目文件中的 AfterBuild
一步MSBuild任务。
Yes, you can perform a Web.config transformation explicitly by invoking the TransformXml
MSBuild task during the AfterBuild
step in your project file.
下面是一个例子:
<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>
相关资源:
- Web.config transformations for App.config files
- Can I specify that a package should be created every time I build a solution?
这篇关于应用Web部署外的Web.Config变换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!