如何将 web.config 设置为“debug=false”通过 MSBuild 扩展包?
我有一个 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 类< /a>,但它没有做任何事情。
我的构建文件如下所示:
<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 并对其做了一些操作,因为资源管理器中的“修改日期”设置为现在,而在我运行脚本之前情况并非如此。但文件中没有明显的变化。我用diff工具对比了MSBuild前后的文件版本,结果是一样的。
我还尝试设置 Key
和 Value
而不是 InnerText
,但这也没有帮助。
知道我做错了什么吗?
I have an WCF Service Application and the web.config is set to debug mode (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>
I would like to set that to "debug=false" via MSBuild Extension Pack (version 3.5.8.0), so that the released version is always automatically in non-debug mode.
Obviously I need to use the XmlFile class, but it doesn't do anything.
My build file looks like this:
<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>
When I run the build script, I only see this:
Test:
XmlFile: C:\MyProject\Build\ServiceClient\web.config
Update Attribute: /configuration/system.web/compilation[@name='debug']. Value:
No errors, no warnings...nothing.
I can see that MSBuild found the web.config and did something with it, because "Date Modified" in the Explorer is set to right now, which wasn't the case before I ran the script. But there is no visible change in the file. I used a diff tool to compare the file versions before and after MSBuild, and they are identical.
I also tried to set Key
and Value
instead of InnerText
, but that doesn't help either.
Any idea what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
我使用的是扩展包版本 3.5.8.0
Try this:
I am using extension pack version 3.5.8.0