我有一个WCF服务应用程序,Web.config设置为调试模式(debug = true):

    <compilation debug="true">
        <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </assemblies>
    </compilation>

我想通过msbuild扩展包(版本3.5.8.0)将其设置为“ debug = false”,以便发布版本总是在非删除模式下自动自动。

显然我需要使用 XMLFILE类, ,但它无能为力。
我的构建文件看起来像这样:

  <Target Name="Test">
    <MSBuild.ExtensionPack.Xml.XmlFile TaskAction="UpdateAttribute" File="$(MSBuildProjectDirectory)\$(BuildDir)\ServiceClient\web.config" XPath="/configuration/system.web/compilation[@name='debug']" InnerText="false"/>
  </Target>

当我运行构建脚本时,我只会看到以下内容:

Test:  
XmlFile: C:\MyProject\Build\ServiceClient\web.config 
Update Attribute: /configuration/system.web/compilation[@name='debug']. Value:

没有错误,没有警告...什么都没有。
我可以看到msbuild找到了web.config并对其进行了一些操作,因为现在设置了Explorer中的“修改日期”,在我运行脚本之前并非如此。但是文件没有明显的更改。我使用了一个差异工具来比较MSBuild之前和之后的文件版本,并且它们是相同的。

我也试图设置 KeyValue 代替 InnerText, ,但这也无济于事。

知道我在做什么错吗?

有帮助吗?

解决方案

尝试这个:

  <Target Name="Test">
    <MSBuild.ExtensionPack.Xml.XmlFile TaskAction="UpdateAttribute" File="web.config" XPath="/configuration/system.web/compilation" Key="debug" Value="false" />
  </Target>

我正在使用扩展包版本3.5.8.0

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top