Home Ask Login Register

Developers Planet

Your answer is one click away!

CamHart February 2016

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

I have the need to dynamically load different versions of the same dll's depending on various situations.

The dll's are created as part of the build process for other projects within the same solution.

For example

    /MainProject - Loads dll's using reflection dynamically

DllProject1 and DllProject2 need to be built before MainProject. MainProject depends on AbstractProject, and through reflection DllProject1/DllProject2. However Visual studio currently forces MainProject to build before DllProject1 and DllProject2. How can I get Visual Studio to build DllProject1/DllProject2 before MainProject?


CamHart February 2016

The solution I found was to do the following:

Open up the .sln file, and change the order in which they projects are listed. Dropping MainProject down to the bottom. Then when I opened up the solution, it had DllProject1 and DllProject2 listed above MainProject in the build order.

Edit: While this works, there is no rhyme or reason for how it works. Randomly switching the order results in randomly changing the build order for projects that have the same dependents.

Jimmy February 2016

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

Post Status

Asked in February 2016
Viewed 2,560 times
Voted 5
Answered 2 times


Leave an answer

Quote of the day: live life