TFS 2012和web.config转换 [英] TFS 2012 and web.config transforms

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

问题描述

我试图让我的TFS构建创建与为构建选择的配置关联的web.config转换.运行构建程序时,我检查了web.config文件,未应用任何转换.当我从VS2012发布时,转换正确工作.

I am trying to have my TFS Build create the web.config transform associated with the configuration I selected for my build. When I run the build I check the web.config file no transforms have been applied. When I a publish from VS2012 the transform works correctly.

我已经设置了TFS 2012(更新2),并具有用于构建的单独服务器.我没有在构建服务器上安装VS2012,但是我将C:\ Program Files(x86)\ MSBuild \ Microsoft \ VisualStudio \ v11.0 \ Web和WebApplications文件夹和文件从开发机复制到了构建服务器.

I have set up TFS 2012 (Update 2), and have a separate server for builds. I don't have VS2012 installed on the build server, but I copied the C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\ Web and WebApplications folders and files from my dev machine to the build server.

我已经在项目中创建了一些配置,并向关联的Web添加了一些转换.{configname} .config.

I have created some configurations in my project, and have added some tranforms to the associated web.{configname}.config.

我已经创建了一个构建,并将要构建的项目-要构建的配置"设置为项目中的一种配置.我注意到它只有调试和发布版本,没有任何我创建的配置. (旁边的问题:是正确的,还是应该显示我创建的所有配置?)

I have created a build and set the Items to Build - Configurations to Build to one of the configurations in my project. I noticed that it only has Debug and Release, it didn't have any of the configurations I created. (Side question: Is that correct, or should it show all the configurations I created?)

因此,我运行构建并检查输出文件夹,并且web.config没有应用转换.我还有什么需要做的吗?

So I run a build and check the output folder and the web.config has not applied the transforms. Is there anything else I need to do?

推荐答案

仅在该位置抛出/p:TransformConfigFiles = true并不会执行任何操作.

Just throwing /p:TransformConfigFiles=true on there won't actually do anything.

您还需要将此目标添加到项目文件中:

You also need to add this target to the project file:

<Target Name="TransformConfigFiles" AfterTargets="AfterBuild" Condition="'$(TransformConfigFiles)'=='true'">
    <ItemGroup>
        <DeleteAfterBuild Include="$(WebProjectOutputDir)\Web.*.config" />
    </ItemGroup>
    <TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(WebProjectOutputDir)\Web.config" />
    <Delete Files="@(DeleteAfterBuild)" />
</Target>

这是我的来源: http://blog.degree.no/2012/03/automatic -config-transformations/

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

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