0

I have an MSBuild XML file with a number of targets, some are a couple of project files, some are full solutions.

What I'm looking for is a way to do something like the following:

MSBuild.exe build.xml /target:Target1 /p:Configuration="Debug;Release" /p:Platform="x86;x64" /m

And have MSBuild kick off a build for each project in Target1 for each combination of configuration and platform:

Debug|x86
Debug|x64
Release|x86
Release|x64

(Also preferably in parallel)

I've found a way to do it for one multiplier (e.g. Configuration OR platform) but not both using ItemGroups but if I try to add in a second multiplier it doesn't work and ends up like this:

Debug|<blank>
Release|<blank>
<blank>|x86
<blank>|x64

Thanks for reading!

Ali1331
  • 1
  • 2
  • You probably want a cross-product, e.g. https://stackoverflow.com/questions/15914145/cross-join-itemgroups-in-msbuild#15928871 – stijn Aug 04 '17 at 08:18

1 Answers1

0

MSBuild: how to build a target for all config/platform combinations?

If you want to build all configuartions for build.xml, you need to build four times with setting property for this projects, for example:

MSBuild.exe build.xml /target:Target1 /p:Configuration="Release" /p:Platform="x86"

Or write a msbuild script to do it:

<?xml version="1.0" encoding="utf-8"?>
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="Build">
      <MSBuild Projects="a.sln" Properties="Configuration=Debug;Platform=x86" />
      <MSBuild Projects="a.sln" Properties="Configuration=Debug;Platform=x64" />
      <MSBuild Projects="a.sln" Properties="Configuration=Release;Platform=x86" />
      <MSBuild Projects="a.sln" Properties="Configuration=Release;Platform=x64" />
   </Target>
 </Project>

If these methods are not effective enough, you can consider Cross-Join ItemGroups in stijn`s comment.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135