mat*_*360 5 xml web-config-transform
我正在尝试设置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>
Run Code Online (Sandbox Code Playgroud)
变换:
<?xml version="1.0" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
输出:
<?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>
Run Code Online (Sandbox Code Playgroud)
我正在使用此工具预览转换:https: //webconfigtransformationtester.apphb.com/
你可以看到它没有做任何事情.我看了很多例子,但显然我错过了一些东西.任何帮助将不胜感激.
(我也试过没有运气):
<?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>
Run Code Online (Sandbox Code Playgroud)
当您将web.config文件的命名空间更改为
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
Run Code Online (Sandbox Code Playgroud)
到
<configuration xmlns:xdt="http://schemas.microsoft.com/.NetConfiguration/v2.0">
Run Code Online (Sandbox Code Playgroud)
当这个变换
<?xml version="1.0" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
应用于调整后的 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>
Run Code Online (Sandbox Code Playgroud)
该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>
Run Code Online (Sandbox Code Playgroud)
更新:正如评论中提到的,web.config 文件的配置根本不应该有任何命名空间。相反,有必要添加此导入
<xdt:Import assembly="AppHarbor.TransformTester"
namespace="AppHarbor.TransformTester.Transforms"/>
Run Code Online (Sandbox Code Playgroud)
到转换文件(至少在使用上述在线转换测试器进行测试时):
<?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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1302 次 |
| 最近记录: |