Reputation: 3201
I'm using XMLUpdate to update multiple config files in subdirectories.
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.
Is this possible?
Upvotes: 0
Views: 304
Reputation: 25351
Yes, I'm pretty sure it is possible, but I think you need to use <ItemGroup>
for that to get a collection of files. 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)"
.
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.
Upvotes: 0