I'm trying to create a filtered item group from another one, where the filtered item group will only contain items from the first group that have a specified file extension.
I'm getting the following error:
error MSB4190: The reference to the built-in metadata "Extension" at position 1 is not allowed in this condition "'%(Extension)'=='.sys'".
When I run this:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="Go"
ToolsVersion="4.0">
<ItemGroup>
<Files Include="X.exe"/>
<Files Include="Y.sys"/>
</ItemGroup>
<ItemGroup>
<SysFiles Include="%(Files.Identity)" Condition="'%(Extension)'=='.sys'">
</SysFiles>
</ItemGroup>
<Target Name="Go">
<Message Text="SysFiles=@(SysFiles)"/>
</Target>
</Project>
Firstly, I can't understand why the meta data isn't allowed at this position? Is it some artificial restriction or unimplemented part of msbuild?
Secondly, what's a concise way of achieving this kind of transform?
Thanks very much.
Ok, I've found if I specify the ItemGroup SysFiles inside target Go, it will work without error.
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