Msbuild TFS2013 Git多项目自动生成web.config转换不工作

Msbuild TFS2013 Git多项目自动生成web.config转换不工作,msbuild,visual-studio-2013,web.config-transform,Msbuild,Visual Studio 2013,Web.config Transform,我无法让MS Build输出转换后的Web.Config文件。我已经使用NuGet package restore设置了构建项目,如中所述。构建的每个部分(包还原、CI、web部署包)都可以工作,转换除外。我已经尝试了基本设置和许多其他选项,但我没有得到任何结果 我以前做过配置转换设置,没有问题。我已经安装了Slow Cheetah,可以预览我当前的转换,并查看它是否有效。当我通过MSBuild.exe在本地运行生成时,转换实际上发生了: TransformWebConfigCore:

我无法让MS Build输出转换后的
Web.Config
文件。我已经使用NuGet package restore设置了构建项目,如中所述。构建的每个部分(包还原、CI、web部署包)都可以工作,转换除外。我已经尝试了基本设置和许多其他选项,但我没有得到任何结果

我以前做过配置转换设置,没有问题。我已经安装了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部署参数化我的
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.
使用G:\MyProject\Web.Debug.config将Web.config转换为obj\Debug\TransformWebConfig\Transformed\Web.config。
管道转换阶段:
发布管道转换阶段
预自动参数化WebConfigConnectionString:
正在创建目录“G:\MyProject\obj\Debug\CSAutoParameterize\transformed\Views\”。
正在将obj\Debug\TransformWebConfig\transformed\Web.config复制到obj\Debug\csautoparametrize\original\Web.config。
自动参数化WebConfigConnectionStringScore:
转换源文件:G:\MyProject\Views\Web.config
应用转换文件:
源文档中没有与“/configuration/connectionString”匹配的元素
不执行SetTokenizedAttribute(转换行6、15)
输出文件:obj\Debug\csautoparametrize\transformed\Views\Web.config
转化成功
PostAutoParameterizationWebConfigConnectionString:
自动连接字符串将obj\Debug\TransformWebConfig\Transformed\Web.config转换为obj\Debug\csautoparametrize\Transformed\Web.config。
然后将参数化文件移动到包中,并删除转换后的文件

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


因此,我有一个经过转换的
web.config
文件,它不会出现在构建输出中。为什么转换发生了,但没有复制到输出目录或web部署包中?

我在这里遇到了同样的问题。这是由Web部署模式引起的。它使用
Web\u包
中的
“project name”.SetParameters.xml
替换部署时的值

由于您想使用
SlowCheetah
,因此需要避免这种情况

通过将web.config中的ConnectionString设置替换为:

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

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

现在,您可以在
connectionStrings.config
文件中添加
SlowCheetah
转换