Reputation: 35
I have an MSBuild TaskItem that contains metadata gathered from a JSON configuration. An example of a single piece of metadata would be
%(Configuration.Object:Name)
and in the case of arrays would be
%(Configuration.Object:Name:0)
%(Configuration.Object:Name:1)
...
When attempting to get this key though, MSBuild is just giving me the exact string instead of interpreting it into the value. Seems as though it can't interpret the colon in the MSBuild file but I've confirmed that the value is present in the metadata by passing the entire TaskItem, @(Configuration)
, into a custom task. I've also tried to use transform syntax to no avail.
What is the syntax to retrieve these values in the MSBuild file?
Upvotes: 0
Views: 83
Reputation: 52
Using colons in metadata names can be problematic because MSBuild does not natively handle them well when referenced directly in this syntax. It interprets the part after the colon as a target framework or other suffix, not as part of the metadata name.
To work around this issue, you can use a custom task or inline task within your MSBuild script to properly handle metadata names that contain colons.
Upvotes: 1
Reputation: 35
I figured it out for all you devs from the future. The answer is Item Functions.
@(Configuration->Metadata('Object:Name'))
Upvotes: 0