views:

3364

answers:

3

Three VS Solutions. First is configured to build as Release, and the other two set to build as Debug.

When running a simple MSBuild script explicitly stating the configuration to build (Debug) the first project is still built as Release.

Sample script:

    <Target Name="Build">
    <ItemGroup>
      <ProjectToBuild Include="$(SolutionsPath)\Solution1.sln"/>
      <ProjectToBuild Include="$(SolutionsPath)\Core\Solution2.sln"/>
      <ProjectToBuild Include="$(SolutionsPath)\UI\Solution3.sln"/>
    </ItemGroup>

    <MSBuild Projects="@(ProjectToBuild)" Targets="Rebuild" Properties="Configuration=Debug;Platform=Any CPU"/>

  </Target>

I have tried variations of the above such as:

    <Target Name="Build">
    <ItemGroup>
      <ProjectToBuild Include="$(SolutionsPath)\Solution1.sln"><Properties>Configuration=Debug</Properties></ProjectToBuild>
      <ProjectToBuild Include="$(SolutionsPath)\Core\Solution2.sln"><Properties>Configuration=Debug</Properties></ProjectToBuild>
      <ProjectToBuild Include="$(SolutionsPath)\UI\Solution3.sln"><Properties>Configuration=Debug</Properties></ProjectToBuild>
    </ItemGroup>

    <MSBuild Projects="@(ProjectToBuild)" Targets="Rebuild" Properties="Platform=Any CPU"/>

  </Target>

but always end up with the same result.

I note there is a similar question but that is specific to TFS and Teambuild. I am talking pure MSBuild with a simple project file created from scratch.

Any ideas?

A: 

Have you tried running with /v:diag?

Also, aside: I think you want "AnyCPU" (no space).

Brian
FYI Any CPU is correct...: error MSB4126: The specified solution configuration "Debug|AnyCPU" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU")
crowleym
+2  A: 
crowleym
A: 

I was getting this same error. The solution was to explicitly specify the target platform with:

msbuild.exe /p:Platform="Any CPU"

This only started happening since I upgraded to windows 7, so I guess it is something to do with that.

Nathan Reed