tags:

views:

69

answers:

1

I have a property group, like so:

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

And I want to batch in an Exec task, like so:

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

But of course, as written I get an error:

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

Can I batch tasks on properties that are lists? I suppose I could hack it by creating a placeholder ItemGroup with metadata and batch on that.

+2  A: 

Since your property is separated by a ; you can directly create an item from it and then batch from that. For example.

<Project ToolsVersion="3.5" DefaultTargets="Demo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  <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'm batching using %(_PlatformItem.Identity) because Identity has the values (Win32 and x64).

Sayed Ibrahim Hashimi
+1 for the .Identity tip. The %() syntax is impossible to google for.
marklam