itemlisttransforms

Cancel
Save
Edit
Sometimes you want to convert an item list into another form. Here's how to do it:

(1) Convert an item list into another item list (vector to vector), with different item-spec's.

Let's say you have
<ItemGroup>
<CppFile Include="a.cpp"/>
<CppFile Include="b.cpp"/>
<CppFile Include="c.cpp"/>
</ItemGroup>

and you want to have a list with a.obj, b.obj, c.obj. Well then you write this:

@(CppFile -> '%(Filename).obj')

%(Filename).obj can be an arbitrary expression.
There are a set of built-in item meta-data, or you can reference your own.

(2) Convert an item list into a string (vector to scalar).

a) You can just write this
@(CppFile)
in a scalar context and it will be evaluated as
a.cpp;b.cpp;c.cpp

b) If you want a different separator, write something like this (say I want a comma):
@(CppFile, ',')
and you'll get
a.cpp,b.cpp,c.cpp

(3) Convert into a string (vector to scalar) with arbitrary separator, but changing the item-spec's as well:

@(CppFile -> '%(Filename).obj', ',')