How do you filter ItemGroup?

I am trying to create a group of filtered elements from another, where a group of filtered elements will contain only elements from the first group with the specified file extension.

I get the following error:

error MSB4190: a reference to the built-in metadata "Extension" at position 1 is not allowed in this condition "% (extension)" == ". sys".

When I ran 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 metadata is not allowed in this position? Is this an artificial limitation or an unrealized part of msbuild?

Secondly, what is a concise way to achieve such a transformation?

Thank you very much.

+4
source share
1 answer

Well, I found that if I specify ItemGroup SysFiles inside the target Go, it will work without errors.

+4
source

Source: https://habr.com/ru/post/1443439/


All Articles