dotnet / dotnet/msbuild

MSBuild.exe orders the build incorrectly when using a solution file.

Open
#421 4 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 6h
Merged PRs (30d)
139

Description

Attached is a test case where MSBuild.exe executes the wrong build order when compiling a solution file with multiple projects.

[TestMSBuildOrder.zip](https://github.com/Microsoft/msbuild/files/83103/TestMSBuildOrder.zip)

Ref: http://blogs.msdn.com/b/visualstudio/archive/2010/12/21/incorrect-solution-build-ordering-when-using-msbuild-exe.aspx

For this test case, I am using the latest MSBuild.exe cloned from the GIT repository and a clean install of Visual Studio 2015 Community Edition.

The attached solution file has three projects in it.

1) Project ClassA has a normal project-level reference to Project ClassB.

2) Project ClassB has a pre-build event which requires Project ConsoleC to be built first. It currently has a solution-level project dependency on Project ConsoleC.

3) Project ConsoleC is a stand-alone command line project.

When compiled using Visual Studio, this solution can be Clean / Build or Rebuild with no errors. Visual Studio sees the build order as: ConsoleC , ClassB , ClassA

(Before launching the next step, adjust the file "Build.bat" to point to the most recent MSBuild.exe on your system.)

When compiling with the attached batch file "Build.bat", MSBuild.exe will always compile the projects in the wrong order (ClassB, ClassA, ConsoleC). This is true whether Project ClassB has a solution-level dependency (as now) or a direct project reference to Project ConsoleC. In neither case will MSBuild.exe create Project ConsoleC first.

I have found no solution to this problem which does not involve building the projects separately.

Much Thanks,
Chris Capon
Robust Technologies Inc.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.