Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild task configuration property

I have three Visual Studio solutions. The first is configured to build as Release, and the other two are 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 the following, but I always end up with the same result.

<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>

I note there is a similar question, MSBuild task - Build fails because one solution being built in release instead of debug, but that is specific to TFS and Teambuild. I am talking pure MSBuild with a simple project file created from scratch.

How can I fix this problem?

like image 875
crowleym Avatar asked Apr 06 '09 12:04

crowleym


2 Answers

Regarding the question of spelling of platform any cpu, it turns out there is an issue, already reported elsewhere here on StackOverflow and Microsoft. It affects MSBuild in general and the entire issue of Platform documentation is omitted in my dotnet v3.5 MSBuild /help. So perhaps this will help someone!

Links

"AnyCPU" vs "Any CPU" in TFS 2010
MSBuild inconsistent platform for "Any CPU" between solution and project

Closed as Won't Fix   
Type:  Bug
ID:  503935  
Opened:  10/26/2009 1:29:12 PM
Access Restriction:  Public  
0 Workaround(s)
5 User(s) can reproduce this bug  

The MSBuild Platform property has a different value for Any CPU depending upon whether you are building a solution or building a project.
- for Solution - use Platform="Any CPU" - with space
- for Project - use Platform="AnyCPU" - without space

like image 84
AnneTheAgile Avatar answered Sep 27 '22 17:09

AnneTheAgile


OK I have found the issue. Nothing related to MSBuild, but instead the solution being built. Posting to save someone else the heartache.

For whatever reason the Debug configuration was configured within the solution like so:

alt text http://www.freeimagehosting.net/uploads/cad0bdf1c0.jpg

So MSBuild was only doing what it was told too...

like image 23
crowleym Avatar answered Sep 27 '22 15:09

crowleym