Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the MSBuild -> (arrow/dash greater/->) operator do?

What does the -> (or ->) operator do inside MSBuild?

Some example code from another question: File Tracker Log file format

<!-- Appended tlog to track custom build events -->
<WriteLinesToFile
  File="$(IntDir)$(ProjectName).write.1.tlog"
  Lines="@(CustomBuildStep-&gt;'^%(Identity)');@(CustomBuildStep-&gt;MetaData('Outputs')-&gt;FullPath()-&gt;Distinct())"/>

Bonus question: What does @(CustomBuildStep-&gt;'^%(Identity)') do in the above code?

like image 475
Nicolas Louis Guillemot Avatar asked Dec 12 '15 05:12

Nicolas Louis Guillemot


1 Answers

The -> operator in MSBuild is the transformation operator. It transforms an item list into a new item list by substituting the string on the right-hand side using metadata of the original items.

The ->'^%(Identity)' magic is partially described in the task batching documentation. The Identity metadata is just the value itself, so that transformation just prepends "^". It also causes batching because of the % sigil, so the whole WriteLinesToFile task gets executed for each CustomBuildStep item.

like image 185
John Calsbeek Avatar answered Sep 22 '22 15:09

John Calsbeek