xml – Web.Config转换不更改任何值
发布时间:2020-12-16 05:33:25 所属栏目:百科 来源:网络整理
导读:我正在尝试设置web.config转换来修改某些值.我正在使用Octopus Deploy给出的这个例子: http://docs.octopusdeploy.com/display/OD/Configuration+files 超薄版本的web.config: ?xml version="1.0" ?configuration xmlns="http://schemas.microsoft.com/.Ne
我正在尝试设置web.config转换来修改某些值.我正在使用Octopus Deploy给出的这个例子:
http://docs.octopusdeploy.com/display/OD/Configuration+files 超薄版本的web.config: <?xml version="1.0" ?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <compilation debug="true" targetFramework="4.0"> </compilation> </system.web> </configuration> 变换: <?xml version="1.0" ?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web> </configuration> 输出: <?xml version="1.0"?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <compilation debug="true" targetFramework="4.0"> </compilation> </system.web> </configuration> 我正在使用此工具预览转换: 你可以看到它没有做任何事情.我看了很多例子,但显然我错过了一些东西.任何帮助将不胜感激. (我也试过没有运气): <?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.web> <compilation debug="false" xdt:Transform="Replace"> </compilation > </system.web> </configuration>
当您更改web.config文件的命名空间时,转换按照上面提到的web.config转换
https://webconfigtransformationtester.apphb.com/的在线预览工具的预期工作
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 至 <configuration xmlns:xdt="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 当这个转变 <?xml version="1.0" ?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web> </configuration> 应用于调整后的web.config <?xml version="1.0" ?> <configuration xmlns:xdt="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <compilation debug="true" targetFramework="4.0"> </compilation> </system.web> </configuration> 从结果中删除debug属性: <?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <compilation targetFramework="4.0"> </compilation> </system.web> </configuration> 更新:如评论中所述,web.config文件的配置根本不应具有任何命名空间.相反,有必要添加此导入 <xdt:Import assembly="AppHarbor.TransformTester" namespace="AppHarbor.TransformTester.Transforms"/> 转换文件(至少在使用上述在线转换测试仪进行测试时): <?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <xdt:Import assembly="AppHarbor.TransformTester" namespace="AppHarbor.TransformTester.Transforms"/> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web> </configuration> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |