[英]How can I change multiple files with XMLUpdate?
I'm using XMLUpdate to update multiple config files in subdirectories. 我正在使用XMLUpdate更新子目录中的多个配置文件。
I thought I would be able to do something like this: 我以为我可以做这样的事情:
<XmlUpdate Namespace="http://schemas.microsoft.com/.NetConfiguration/v2.0"
XmlFileName="\\$(BuildEnvironment)\websites\*.config"
Xpath="//configuration/appSettings/add[@key='Site']/@value"
Value="sitename"
/>
Where I have the following structure: 我有以下结构:
Websites
|
|-site1\web.config
|
|-site2\web.config
|
|-site3\web.config
So the idea is that rather than writing the xmlupdate task many times, I would be able to use the above and update many config files at once. 因此,我的想法是,与其多次编写xmlupdate任务,不如使用上述方法并一次更新许多配置文件。
Is this possible? 这可能吗?
Yes, I'm pretty sure it is possible, but I think you need to use <ItemGroup>
for that to get a collection of files. 是的,我非常确定这是可能的,但是我认为您需要使用<ItemGroup>
来获取文件集合。 Something like: 就像是:
<ItemGroup>
<documentation_files Include="\\$(BuildEnvironment)\websites\**web.config" />
</ItemGroup>
<XmlUpdate
XmlFileName="@(documentation_files)"
Xpath="//configuration/appSettings/add[@key='Site']/@value"
Value="sitename" />
I left the Value
static, but if you want to change it to the current folder, you can use something like Value="%(documentation_files.RecursiveDir)"
. 我将Value
保留为静态,但是如果要将其更改为当前文件夹,则可以使用Value="%(documentation_files.RecursiveDir)"
。
Note: This code is just an example. 注意:此代码仅是示例。 You may have to change it a bit to get what you want, but I hope it helps you. 您可能需要稍作更改才能获得所需的东西,但是我希望它能对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.