Can I work based on a property (not just elements)?

I have a group of properties, for example:

<PropertyGroup> <Platform>Win32;x64</Platform> </PropertyGroup> 

And I want to execute the package in the Exec task, for example:

 <Exec Command='devenv MySolution.sln /Build "Release|%(Platform)"' /> 

But of course, as written, I get an error message:

 error MSB4095: The item metadata %(Platform) is being referenced without an item name. Specify the item name by using %(itemname.Platform). 

Can I do batch jobs on properties that are lists? I guess I could hack it by creating a placeholder ItemGroup with metadata and package.

+4
source share
1 answer

Because your property is separated by a symbol ; , you can directly create an element from it, and then execute the package. For instance.

 <Project ToolsVersion="3.5" DefaultTargets="Demo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Platform>Win32;x64</Platform> </PropertyGroup> <Target Name="Demo"> <ItemGroup> <_PlatFormItem Include="$(Platform)"/> </ItemGroup> <Message Text="Platform: $(Platform)"/> <Message Text="_PlatFormItem: @(_PlatFormItem)"/> <Message Text="Platform.Identity: %(_PlatFormItem.Identity)"/> <Exec Command='devenv MySolution.sln /Build "Release|%(_PlatFormItem.Identity)"' /> </Target> </Project> 

Here I do batch processing using %(_PlatformItem.Identity) , because Identity has values ​​(Win32 and x64).

+13
source

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


All Articles