Visual Studio 2010: How to Enforce Build Order of Projects in a Solution

Visual Studio 2010: How to enforce build order of projects in a solution?

Nick Craver mentioned checking the Configuration Manager to ensure you have the project selected to build for a given configuration.

However, to set the build order for multiple projects in a solution right click the solution and choose "Project Build Order..." from the context menu.

Project Build Order in Visual Studio 2010?

I believe that Visual Studio builds these projects in the order they appears in solution. If you need to adjust the build order of projects you can use Project Dependencies (do not confuse with .NET References). When you add .NET reference from one .NET project to another inside you Visual Studio solution the Visual Studio automatically creates project dependency. To modify project dependencies manually do the following:

  1. Right-click on the solution in Solution Explorer.
  2. Select Project Dependencies
  3. From the drop-down list select project you want to add dependencies to.
  4. Select dependencies for this project.

Also you can view the resulting build order by switching to the tab Build Order.

How to change Build Order in VS2010

If you right-click your solution from within Visual Studio and select properties a dialog box will pop up allowing you to setup different solution configuration behavior. You can create a test or debug configuration and choose which projects you want to build or not build.

Solution Property Pages

Print out full project build order in Visual Studio 2010

I'm answering my own just so i can mark it as answered. Thanks to PVitt's comment, i thought of getting a full build output from our CM group and parsing it with regex to get the full list. In 10 minutes i had both the list the projects where started building and also the order in which they finished. Even more than I needed.
Thanks again Stack Overflow.

How can I change Visual Studio's build order for reflection based project dependencies?

Visual Studio allows you to set explicit build dependencies in the solution (as opposed to implicity dependencies e.g. from traversing your references). Just right-click on your solution and find the Project Dependencies menu item:

Project Dependencies menu item

The dialog that opens will allow you to set build dependencies and show you the calculated build order (you can affect the order by changing the dependencies).

VS2010 LNK1181 when rebuilding project with dependency

A rebuild in Visual Studio cleans and builds the projects one by one, so what probably ends up happening is

  • Project A is cleaned.
  • Project A is compiled.
  • Project B is cleaned, removing parts of the output from Project A due to the same output directory.
  • Project B fails building due to missing dependencies.

More discussion here.

Visual Studio Builds Projects Every Time I Run

The cause could be many things, so without having your solution + projects, we can only guess.

The typical way I handle this problem is by narrowing it down with a binary search. That is,

  1. I build everything.
  2. Next I find something in the middle of the build order and build that project. If something that that project depends on is the culprit, you'll experience the issue. If something that it doesn't depend on has the problem you won't (i.e. it will say all projects skipped).
  3. Now you repeat this process until you narrow it down to (hopefully) the project that has started causing the problem.

This (of course) only works if there is a single project that introduced the new problem (which is likely).

One of the culprits in my specific situation was having an x64 project reference an x86 project that wasn't selected to be built in the x64 configuration.



Related Topics



Leave a reply



Submit