首页 > 解决方案 > Building only particular project in the Visual Studio solution

问题描述

In Visual Studio (C#) I have a solution with dozens of projects. Let say I have projects: A, B, C, D, E.

Project "C" depends on "A" and "B".

"A" and "B" are not depending on any projects.

In the solution explorer I select project "C", then select "Build" (right mouse click in context menu).

But Visual Studio, along with all information in the output, displays me the list of errors in the projects "D" and "E". I.e it is trying to build other projects too.

But I did not asked for that. I want to build project "C" (also projects "A" and "B" should be built as dependendcies).

Question: How can I build only that project I want (and its dependencies). And turn off this unwanted behaviour, like trying to compile projects which are in the same solution, but are not linked to the project I want to build.

UPDATE

Configuration manager looks like that:

config-manager

If I understand correctly all projects are marked, because they should be built when I build the whole solution. I think I can unmark all unwanted projects and leave only A, B and C.

And when I will need to build the whole solution, I will need to mark all projects again.

Is it the only solution?

I supposed when I select a project in the solution explorer and build only this project, only this project and its dependencies should be built. Did I miss something here?

标签: visual-studio

解决方案


Go to Project --> Project Dependencies, select the project and then select what projects it depends on.

enter image description here


You may also want to look at the Microsoft Documentation on how to Exclude Projects from a Build. You can create a Custom Build and exclude the projects you don't want from it.


推荐阅读