小编Mar*_*o G的帖子

如何在一个web.config元素上应用两个不同的转换?

从我的VS2010部署项目中,我想对web.config中的一个元素的两个不同属性应用两种不同的转换.请考虑以下web.config片段:

<exampleElement attr1="false" attr2="false" attr3="true" attr4="~/" attr5="false">
  <supportedLanguages>
    <!-- Some more elements here -->
  </supportedLanguages>
</exampleElement>
Run Code Online (Sandbox Code Playgroud)

现在我如何在转换后的web.config中更改属性'attr1'并删除属性'attr5'?我知道如何执行单个转换:

<exampleElement attr1="true" xdt:Transform="SetAttributes(attr1)"></exampleElement>
Run Code Online (Sandbox Code Playgroud)

和:

<exampleElement xdt:Transform="RemoveAttributes(attr5)"></exampleElement>
Run Code Online (Sandbox Code Playgroud)

但我不知道如何结合这些变换.任何人?

编辑:

无法回答我自己的问题,但解决方案似乎是:

似乎可以使用不同的转换重复相同的元素,如下所示:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <exampleElement attr1="true" xdt:Transform="SetAttributes(attr1)"></exampleElement>
    <exampleElement xdt:Transform="RemoveAttributes(attr5)"></exampleElement>
</configuration>
Run Code Online (Sandbox Code Playgroud)

如上所述,这似乎有效,但我不确定这是否是web.config转换语法的预期用途.

msbuild element web-config transform visual-studio-2010

12
推荐指数
1
解决办法
3697
查看次数