app.config转换 [英] app.config Transformations

查看:360
本文介绍了app.config转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个粉丝,加入了 web.config转换在Visual Studio 2010中。另请参见 Scott Hanselman最近在MIX2011上的演讲



这个功能(至少出现)只能用于Web项目,有什么好处。



在我们的解决方案中,我们有几个Windows服务连接到不同的数据库,这取决于它们所部署的环境。



有没有人想出一个好的,整洁的方式来实现类似的app.config转换功能?



注意:我们正在使用TFS 2010以连续集成方式构建我们的解决方案。

解决方案

您可以使用XML转换功能与任何XML文件 - 我们一直这样做。可以通过MSBuild任务获得。



尝试将以下内容添加到您的构建脚本中:

 code>< UsingTask TaskName =TransformXml
AssemblyFile =$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll />

< TransformXml Source =Path\To\Your\Xml.config
Transform =Path\To\Your\Xml。$(Configuration)。 config
Destination =Path\To\Your\Output.config/>


I'm a huge fan of the addition of web.config transformations in Visual Studio 2010. See also Scott Hanselman's recent talk at MIX2011.

What sucks is that this functionality (appears at least) to only be available to web projects.

In our solution we have several Windows Services that connect to a different database dependant on the environment they are deployed under.

Has anyone come up with a nice, tidy way of achieving similar 'app.config transformation' functionality?

Note: We are using TFS 2010 to build our solutions in a Continuous Integration manner.

解决方案

You can use the XML transformation functionality with any XML file - we do this all the time. It's available via an MSBuild task.

Try adding the following to your build script:

<UsingTask TaskName="TransformXml"
           AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>

<TransformXml Source="Path\To\Your\Xml.config"
              Transform="Path\To\Your\Xml.$(Configuration).config"
              Destination="Path\To\Your\Output.config" />

这篇关于app.config转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆