tags:

views:

198

answers:

2

I have the following in a AfterGet target in TFS.

<ItemGroup>
  <AssemblyInfoFiles Include="$(SolutionRoot)\**\*assemblyinfo.cs" />
</ItemGroup>
<WriteLinesToFile
        File="@(AssemblyInfoFiles)"
        Lines="AssemblyInformationalVersion(&quot;$(LabelName)&quot;)]"
        Overwrite="false"/>

The ItemGroup includes multiple files, but the WriteLinesToFile only expects a single file.

And logs the following error: error MSB4094: "XXXX;YYYY;ZZZZ" is an invalid value for the "File" parameter of the "WriteLinesToFile" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem".

How do I pass each item from the ItemGroup into the WriteLinesToFile Task?

A: 

You can use batching : try

<ItemGroup>
  <AssemblyInfoFiles Include="$(SolutionRoot)\**\*assemblyinfo.cs" />
</ItemGroup>
<WriteLinesToFile
        File="%(AssemblyInfoFiles.FullPath)"
        Lines="AssemblyInformationalVersion(&quot;$(LabelName)&quot;)]"
        Overwrite="false"/>

Hope it helps !

Cédric Rup
I didnt see your answer before posting my own, sorry.
Morten Lyhr
No problem ;o) If you want to do powerful things wish MSBuild, you should learn about batching, transforms and metadata
Cédric Rup
A: 

I found the answer here: http://timstall.dotnetdevelopersjournal.com/foreach_loop_in_msbuild.htm

Morten Lyhr