I am trying to build an MSBuild target that is to take a certain file in a list of directories, and then copy that file with a different name into the same directory. The "destination" name is directly dependent upon the directory.
Let's illustrate with an example:
|-\Source\MySolution.ProjectFoo\
| -- App.config.tpl
| -- MySolution.ProjectFoo.exe
| -- (Target) MySolution.ProjectFoo.exe.config.tpl
|-\Source\MySolution.ProjectBar\
| -- App.config.tpl
| -- MySolution.ProjectBar.exe
| -- (Target) MySolution.ProjectBar.exe.config.tpl
I have began building my ItemGroup
like this:
<ItemGroup>
<AppConfigTemplates Include="Source\**\App.config.tpl">
<Correlate>%(RecursiveDir)</Correlate>
</AppConfigTemplates>
<ExeFiles Include="Source*\**\*.exe">
<Correlate>%(RecursiveDir)</Correlate>
</ExeFiles>
</ItemGroup>
I was hoping to be able to batch on the Correlate
metadata property. Something like:
<Copy Batch="%(Correlate)" SourceFiles="%(AppConfigTemplates.FullPath)"
DestinationFiles="%(ExeFiles.FullPath).config.tpl" />
How can I achieve this?