Pat*_*att 5 web-config-transform
我正在尝试创建一个web.config转换文件,如果名称包含单词"Config",它将把appSettings值列表更改为"false".
<add name="Config.Showlog" value ="true" />
Run Code Online (Sandbox Code Playgroud)
转换文件有
<appSettings>
<add xdt:Transform="SetAttributes(value)"
value="false"
xdt:Locator="Condition(starts-with(@name,'Config')"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
Visual Studio 2010显示错误:
条件正好需要1个参数.
我也尝试使用Xpath作为xdt:定位器的属性并得到相同的错误.似乎问题来自VS 2010如何解析内部Condition()或表达式Xpath().
你怎么解决这个问题?
我想出了以下解决方案:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add xdt:Transform="SetAttributes(value)"
value="false"
xdt:Locator="Condition(contains(@key, 'Config'))"/>
</appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这会将属性中包含“Config”的元素value的所有属性设置为“false”。<appSettings><add>key
<add key="SomeOtherAppSettings"
value="OriginalValue" />
<add key="An entry containing Config in the key attribute"
value="false" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3453 次 |
| 最近记录: |