MaYaN
MaYaN

Reputation: 7006

How can I transform MsBuild ItemGroup into a PropertyGroup?

I have an ItemGroup as:

<ItemGroup>
    <FilesToExclude Include="One.dll;Two.dll" />
</ItemGroup>

I want to be able to have a property group which has the concatenated result of the above dlls producing (excluding the double quotes):

"-x!One.dll -x!Two.dll"

I am currently using:

    <tmp>
      -x! @(FilesToExclude)
    </tmp>

which is producing:

"-x!One.dll;Two.dll"

Any ideas?

Upvotes: 0

Views: 394

Answers (1)

Nikerboker
Nikerboker

Reputation: 843

Specify the delimiter for concatenation:

<ItemGroup>
  <FilesToExclude Include="One.dll;Two.dll"/>
</ItemGroup>

<PropertyGroup>
  <tmp>-x!@(FilesToExclude, ' -x!')</tmp>
</PropertyGroup>

To be confident of evaluation order in this sample move the PropertyGroup definition inside a Target.

Upvotes: 2

Related Questions