TFS Build 未按预期转换 web.config [英] TFS Build not transforming web.config as expected

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

问题描述

目标是让 TFS 构建和部署 2 种以上不同的配置,并让 web.config 转换文件在其输出中包含预期的内容.这在 ASP.NET MVC 项目中.

Web.Debug.Config - 输出正确的转换!

  • 没有对 .csproj 进行任何后期构建或部署的修改.
  • 是否有任何 xdt 属性被滥用或丢失?
  • 构建定义中没有指定 MSBuild 参数.
  • 是否正确设置了 web.config 构建操作?
  • 我们没有使用网络部署包或任何东西.只是希望在以后将这些输出 xcopy 到它们的各个网络服务器位置.
  • 如果我遗漏了任何重要信息,请发表评论,我会提供更多相关信息!

    解决方案

    以前我一直在做类似其他答案的事情.但是,我刚刚发现似乎是解决此问题的更好方法.只需将/p:UseWPP_CopyWebApplication=true/p:PipelineDependsOnBuild=false"添加到您的 MSBuild 参数中.我刚刚在我的一个 TFS 版本上进行了尝试,它工作得很好.

    我在这里找到了这个很棒的提示:http://www.andygeldman.com/index.php/2011/10/web-and-app-config-transformations-with-tfs-build.

    The goal is to have TFS build and deploy 2+ different configurations, and have the web.config transform files include the intended content in their output. This in an ASP.NET MVC project.

    Web.Debug.Config - see on PasteBin.
    Web.Release.Config - see on PasteBin

    The 2 transformed config files have their Build Action set to None. This was modified because all 3 web.*.config files were being included in the deployment.

    TFS is configured correctly to build and deploy both configurations. It deploys to the 2 drop locations as expected. There are no MSBuild Arguments specified in the build definition.

    Problem: The 2 built and deployed web sites have the same web.config file. Basically it's as if the transformed files did not exist.

    Expected: the changes specified (xdt:Transform="Replace" and xdt:Transform="Remove") would be present in the web.config files.

    How can you configure your project or TFS to ensure the web.config transformations are processed and their outputs deployed to the correct deployment locations? What else can I check/modify?

    • Have confirmed that the transformations are good -- Vishal's Joshit's tutorial with the MSBuild on the command line output the correct transformations!
    • No modifications have been made to the .csproj for any post-build or deployment.
    • Are any xdt attributes being misused or missing?
    • There are no MSBuild Arguments specified in the build definition.
    • Are the web.config Build Actions set correctly?
    • We're not using web deployment packages or anything. Simply expecting to xcopy these outputs over to their various webserver locations at a later date.

    If I'm missing any important information, please leave a comment, and I'll include any more relevant information!

    解决方案

    Previously I had been doing something similar to the other answers. However, I just found what seems to be a better solution to this problem. Just add "/p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false" to your MSBuild arguments. I just tried this out on one of my TFS builds and it works just fine.

    I found this great tip here: http://www.andygeldman.com/index.php/2011/10/web-and-app-config-transformations-with-tfs-build.

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

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