tags:

views:

48

answers:

1

Hello.

I am trying to use MSBuild to build a solution with a specified target platform (I need both binaries, x86 and x64). This is how I tried it:

C:\WINDOWS\Microsoft.NET\Framework\v3.5>MsBuild SolutionPath\Solution.sln /t:Rebuild /p:Configuration=Release /p:Platform="x86"

However the build always fails if the platform is different from "Any CPU". What am I doing wrong?

EDIT: This is the while ouptut MSBuild prints:

C:\WINDOWS\Microsoft.NET\Framework\v3.5>MsBuild SolutionPath\Solution.sln /t:Rebuild /p:Configuration=Release /p:Platform="x86" Microsoft (R) Build Engine Version 3.5.30729.1 [Microsoft .NET Framework, Version 2.0.50727.3082] Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 1.7.2010 8:28:10. Project "SolutionPath\Solution.sln" on node 0 (Rebuild targe t(s)). SolutionPath\Solution.sln : error MSB4126: The specified sol ution configuration "Release|x86" is invalid. Please specify a valid solution c onfiguration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those prope rties blank to use the default solution configuration. Done Building Project "SolutionPath\Solution.sln" (Rebuild t arget(s)) -- FAILED.

Build FAILED.

"SolutionPath\Solution.sln" (Rebuild target) (1) -> (ValidateSolutionConfiguration target) -> SolutionPath\Solution.sln : error MSB4126: The specified s olution configuration "Release|x86" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.ex e Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those pro perties blank to use the default solution configuration.

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.03

If I try to build it for x86/x64 with devenv it works perfectly, however I am trying to set up a build server without installing all the necessary versions of visual studio. By the way, if there is a better free tool (that supports framework 4) out there, I'd love to hear about it.

+1  A: 

If you want to build your solution for x86 and x64, your solution must be configured for both platform. Actually you just have a AnyCpu config.

How to check the available configuration for a project

To check the available configuration for a given project, open the project file (*.csproj for example) and look for a PropertyGroup with the right Condition.

If you want to build in Release mode for x86, you must have in your project file, something like this :

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
  ...
</PropertyGroup>

How to create and edit configuration in Visual Studio

Configuration Manager panel

New solution platform button

New solution platform panel

How to create and edit configuration (on MSDN)

madgnome