我使用XMLUpdate更新子目录中的多个配置文件。
我以为我可以做这样的事情:
<XmlUpdate Namespace="http://schemas.microsoft.com/.NetConfiguration/v2.0"
XmlFileName="\\$(BuildEnvironment)\websites\*.config"
Xpath="//configuration/appSettings/add[@key='Site']/@value"
Value="sitename"
/>
我有以下结构:
Websites
|
|-site1\web.config
|
|-site2\web.config
|
|-site3\web.config
所以我的想法是,不是多次编写xmlupdate任务,而是能够使用上述内容并一次更新许多配置文件。
这可能吗?
答案 0 :(得分:0)
是的,我非常确定这是可能的,但我认为您需要使用<ItemGroup>
来获取文件集合。类似的东西:
<ItemGroup>
<documentation_files Include="\\$(BuildEnvironment)\websites\**web.config" />
</ItemGroup>
<XmlUpdate
XmlFileName="@(documentation_files)"
Xpath="//configuration/appSettings/add[@key='Site']/@value"
Value="sitename" />
我离开了Value
静态,但如果您想将其更改为当前文件夹,则可以使用Value="%(documentation_files.RecursiveDir)"
之类的内容。
注意:此代码只是一个示例。你可能需要改变它以获得你想要的东西,但我希望它可以帮到你。