RationalGeek
RationalGeek

Reputation: 9599

string replace over collection of files

I am writing an MsBuild script to process config files and do transforms. I am creating a collection of a .Dev.config files thusly:

<ItemGroup>
    <DevConfigFiles Include="..\Source\**\*.Dev.config"/>
</ItemGroup>

This works fine. Doing a task against %(DevConfigFiles.Identity) gives me what I would expect. I'd like to take that collection, and create a corresponding collection of the same file names, but with ".Dev.config" replaced with ".config".

I can't figure out the MsBuild syntax to get this done. What is the best way to accomplish this?

NOTE: I would consider alternative techniques for getting the list of *.config files and the corresponding list of *.Dev.config files, but really I'd like to understand the MsBuild syntax for calling string functions over a collection. That is the part that is tripping me up.

ANOTHER NOTE: I can't use the %(Extension) metadata in this case because it doesn't remove the ".Dev" portion of the string. It considers that part of the filename.

Upvotes: 2

Views: 798

Answers (1)

Bronumski
Bronumski

Reputation: 14272

Similar SO question where the OP wants to take a collection of files and copy them with the name being based on the original string.

MSBUild: Copy files with a name based on the original (following a pattern)

Upvotes: 2

Related Questions