Building all projects of a solution with a mixture of x86 and “any cpu” projects using MSBuild

StackOverflow https://stackoverflow.com/questions/9483437

  •  13-11-2019
  •  | 
  •  

Question

Is it possible to be able to build all projects of a solution with x86 and "any cpu" projects in it from MSBuild?

Ideally I would like a solution that would work regardless of whether the project has multiple platforms or not because it's often not obvious when you add a project that defaults to x86 and you have to spend a lot of time figuring out why your project isn't being built.

Was it helpful?

Solution 2

If your solution has multiple platforms you want to target, it's possible to define multiple configurations to build in your tfsbuild.proj file:

<ItemGroup>
  <ConfigurationToBuild Include="$(BuildFlavour)|Any CPU">
    <FlavorToBuild>$(BuildFlavour)</FlavorToBuild>
    <PlatformToBuild>Any CPU</PlatformToBuild>
  </ConfigurationToBuild>
  <ConfigurationToBuild Include="$(BuildFlavour)|x86">
    <FlavorToBuild>$(BuildFlavour)</FlavorToBuild>
    <PlatformToBuild>x86</PlatformToBuild>
  </ConfigurationToBuild>
</ItemGroup>

MSBuild and TFSBuild will build any projects that match either configurations.

OTHER TIPS

Try to use solution-level platform called "Mixed Platforms". See this post.

  msbuild.exe MixedProjects.sln /p:"Platform=Mixed Platforms" /p:Configuration=Debug
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top