In the following ItemDefinitionGroup
you can create a copy of the current metadata, and then call Replace :
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" DefaultTargets="Dump" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemDefinitionGroup> <SomeItem> <SomeMetaData>foo,bar,baz</SomeMetaData> </SomeItem> </ItemDefinitionGroup> <ItemGroup> <SomeItem Include="one;two" /> </ItemGroup> <ItemDefinitionGroup> <SomeItem> <SomeMetaData>$([System.String]::Copy('%(SomeMetaData)').Replace('bar',''))</SomeMetaData> </SomeItem> </ItemDefinitionGroup> <Target Name="Dump"> <Message Text="SomeItem.SomeMetaData: @(SomeItem -> '%(Identity)=%(SomeMetaData)') " /> </Target> </Project>
Here is the output when starting with MSBuild 14:
> MSBuild .\foo.proj Microsoft (R) Build Engine version 14.0.25420.1 Copyright (C) Microsoft Corporation. All rights reserved. Build started 2/17/2017 7:09:48 PM. Project "D:\temp\mb\foo.proj" on node 1 (default targets). Dump: SomeItem.SomeMetaData: one=foo,,baz;two=foo,,baz Done Building Project "D:\temp\mb\foo.proj" (default targets). Build succeeded. 0 Warning(s) 0 Error(s) Time Elapsed 00:00:00.03
source share