【问题标题】:How to transform config files with slow cheetah on build in a web project如何在 web 项目中使用慢 cheetah 转换配置文件
【发布时间】:2014-03-04 13:54:09
【问题描述】:

所以我想要完成的是转换构建中的所有配置文件。

  • Web.config
  • App.config
  • ....config.xml

在项目文件中,它们都如下所示:

<None Include="FooBar.config.xml">
  <TransformOnBuild>true</TransformOnBuild>
</None>
<None Include="FooBar.config.Release.xml">
  <DependentUpon>FooBar.config.xml</DependentUpon>
  <IsTransformFile>True</IsTransformFile>
</None>

Windows 服务和 Windows 应用程序一切正常。但是对于 web 项目,缓慢的 cheetah 并没有进行转换。经过一番研究,我发现了这一点: “对于 Web 项目,文件在您发布或打包应用程序时进行转换。”从慢猎豹扩展页面。事实上,当我发布 Web 项目时,转换已正确完成。

那么我怎样才能改变缓慢的 cheetah 默认行为并在构建服务器上执行所有转换?

环境:

  • TFS 2010
  • 构建服务器上的慢 cheetah 版本:1.0.10727.0

【问题讨论】:

    标签: msbuild slowcheetah


    【解决方案1】:

    那么我是如何解决这个问题的。 我已经编辑了 SlowCheetah 的目标文件

    这可以在 C:\Users\BuildUser\AppData\Local\Microsoft\MSBuild\SlowCheetah\v1 中找到 在您的构建服务器上。打开文件并找到以下行:

    <BuildDependsOn Condition=" '$(IsWap)'!='true' ">
        <BuildDependsOn> 
          $(BuildDependsOn);
          TransformAllFiles
        </BuildDependsOn>
    

    我已经删除了条件。

    结果:

    <BuildDependsOn> 
      $(BuildDependsOn);
      TransformAllFiles
    </BuildDependsOn>
    

    【讨论】:

    • 你确定这样做没有后果吗?出现这种情况一定是有原因的。
    • 条件存在,因此它只发生在发布时。但我们不使用发布。我们有自定义 Wix 安装程序。
    【解决方案2】:

    现在有更好的解决方案。只需使用 transformxml msbuild 任务。我不认为缓慢的 cheetah 会继续维护,因为这个功能是 msbuild 的原生功能。更多https://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx

    【讨论】:

    • 恐怕它只适用于 web.config。对于 app.config,你仍然需要 slowcheetah
    猜你喜欢
    • 2013-08-22
    • 2014-05-15
    • 2013-03-10
    • 1970-01-01
    • 2012-05-15
    • 2016-10-18
    • 2018-07-04
    • 1970-01-01
    • 2012-05-25
    相关资源
    最近更新 更多