【问题标题】:TFS2013 Git multi-project automated build web.config transform not workingTFS2013 Git 多项目自动构建 web.config 转换不起作用
【发布时间】:2014-06-09 20:34:37
【问题描述】:

我无法让 MS Build 输出转换后的 Web.Config 文件。我已经按照NuGet docs 中的描述使用 NuGet 包还原设置了构建项目。除了转换之外,构建的每个部分(包还原、CI、Web 部署包)都有效。我已经尝试了基本设置和custom project file 以及许多其他选项,但我没有得到任何结果。

我之前已经完成了配置转换设置,没有问题。我安装了 Slow Cheetah,可以预览我当前的转换并查看它是否有效。当我通过MSBuild.exe 在本地运行构建时,转换实际上发生了:

    TransformWebConfigCore:
  Transforming Source File: G:\MyProject\Web.config
    Applying Transform File: G:\MyProject\Web.Debug.config
    Output File: obj\Debug\TransformWebConfig\transformed\Web.config
  Transformation succeeded

(如果我查看 -v 输出,我可以看到单独的转换运行)

然后 Web Deploy 参数化我的web.config

Transformed Web.config using G:\MyProject\Web.Debug.config into obj\Debug\TransformWebConfig\transformed\Web.config.
PipelineTransformPhase:
  Publish Pipeline Transform Phase
PreAutoParameterizationWebConfigConnectionStrings:
  Creating directory "G:\MyProject\obj\Debug\CSAutoParameterize\transformed\Views\".
  Copying obj\Debug\TransformWebConfig\transformed\Web.config to obj\Debug\CSAutoParameterize\original\Web.config.
AutoParameterizationWebConfigConnectionStringsCore:
  Transforming Source File: G:\MyProject\Views\Web.config
    Applying Transform File: <?xml version="1.0"?>
          <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
            <connectionStrings>
              <add
                connectionString="{% token='$(ReplacableToken_#(parameter)_#(tokennumber))' xpathlocator='name' parameter='$(name)-Web.config Connection String' description='$(name) Connection String used in web.config by the application to access the database.' defaultValue='$(connectionString)' tags='SqlConnectionString' %}"
                xdt:Transform="SetTokenizedAttributes(connectionString)" xdt:SupressWarnings="True" />
            </connectionStrings>
          </configuration>
    No element in the source document matches '/configuration/connectionStrings'
    Not executing SetTokenizedAttributes (transform line 6, 15)
    Output File: obj\Debug\CSAutoParameterize\transformed\Views\Web.config
  Transformation succeeded
PostAutoParameterizationWebConfigConnectionStrings:
  Auto ConnectionString Transformed obj\Debug\TransformWebConfig\transformed\Web.config into obj\Debug\CSAutoParameterize\transformed\Web.config.

然后将参数化文件移动到包中,并删除转换后的文件。

将 obj\Debug\CSAutoParameterize\transformed\Web.config 复制到 obj\Debug\Package\PackageTmp\Web.config。 删除文件“obj\Debug\CSAutoParameterize\transformed\Web.config”。

所以我有一个转换后的web.config 文件,它最终不会出现在我的构建输出中。为什么转换发生但没有被复制到输出目录或 web 部署包?

【问题讨论】:

    标签: msbuild visual-studio-2013 web.config-transform


    【解决方案1】:

    我在这里遇到了同样的问题。这是由 Web 部署模式引起的。它使用 Web_Package 中的 "project name".SetParameters.xml 替换 Deploy 上的值。

    既然你想使用SlowCheetah,你需要绕过这个。

    您可以通过以下方式替换 web.config 中的 connectionstrings 设置来完成此操作:

        <connectionStrings configSource="connectionStrings.config">
        </connectionStrings>
    

    当然,您需要 connectionStrings.config 文件。您可以手动创建它并放入 originasl connectionStrings 部分。 该节点应该是文件中的唯一节点。

    现在您可以在您的connectionStrings.config 文件中添加SlowCheetah Transform。

    【讨论】:

      猜你喜欢
      • 2013-01-03
      • 2016-05-26
      • 2016-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-06
      • 1970-01-01
      • 2021-12-10
      相关资源
      最近更新 更多