0

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?

Piers Karsenbarg
  • 3,105
  • 5
  • 31
  • 67

1 Answers1

0

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.

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55