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->'^%(Identity)');@(CustomBuildStep->MetaData('Outputs')->FullPath()->Distinct())"/>
Bonus question: What does @(CustomBuildStep->'^%(Identity)')
do in the above code?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With