MSBuild:正在为给定环境转换app.config,但未转换app.exe.config

MSBuild:正在为给定环境转换app.config,但未转换app.exe.config,msbuild,web-config,msbuild-task,msbuild-4.0,msbuildcommunitytasks,Msbuild,Web Config,Msbuild Task,Msbuild 4.0,Msbuildcommunitytasks,我正在使用MSBuild.exe构建我们的应用程序。除了App.Config,我还有App.prod.Config、App.qa.Config、App.dev.Config文件 在命令行中,我输入以下命令 C:\XXX\MyProject> C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe myBuildFile.build /p:Configuration=DEV 在上面的命令中,查找app.config和app.dev

我正在使用MSBuild.exe构建我们的应用程序。除了App.Config,我还有App.prod.Config、App.qa.Config、App.dev.Config文件

在命令行中,我输入以下命令

C:\XXX\MyProject> C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe myBuildFile.build /p:Configuration=DEV
在上面的命令中,查找app.config和app.dev.config文件,转换app.dev.config中的占位符并使用app.dev.config文件中的条目生成app.cofig文件

编译项目后,将创建app.exe.config文件。这一切对我来说都很好

但是对于生产,我得到了正确转换的app.config文件,但是app.exe.config文件与默认的app.config文件相同,没有任何转换

以下是app.prod.config文件:

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <connectionStrings>
       <add name="EventStore"
             connectionString="XXXXXXXXXXX"
             providerName="System.Data.SqlClient"
             xdt:Transform="SetAttributes"
             xdt:Locator="Match(name)"/>
    <add name="Profile"
         connectionString="XXXXXX"
         providerName="System.Data.SqlClient"
         xdt:Transform="SetAttributes"
         xdt:Locator="Match(name)"/>
    <add name="IdentityDB"
         connectionString="XXXXXXXXXXXXXXXXXXXXXXXX"
         providerName="System.Data.OracleClient"
         xdt:Transform="SetAttributes"
         xdt:Locator="Match(name)"/>
  </connectionStrings>
  <appSettings>
    <add key="ApplicationName"
         value="PROD"
         xdt:Transform="SetAttributes"
         xdt:Locator="Match(key)"/>
     </appSettings>
  <system.web>
    <compilation xdt:Transform="RemoveAttributes(Debug)" />
  </system.web>
</configuration>

默认情况下,web.config仅在发布时转换。如果要转换app.config或xml文档,那么最好的选择是安装名为

的Visual Studio扩展来执行app.config转换?是SlowCheetah还是您正在脚本的某个地方运行TransformTask?