Darrin Doherty
Darrin Doherty

Reputation: 870

How to build only the selected class library project in Visual Studio, not any dependencies

We have a very large solution. I'd like to find a way to select a C# class library project in Visual Studio and build only that project.

The solution is composed of non-managed C++, managed C++, and C# projects.

Turning on "Only build startup projects and dependencies on Run" results in very good performance with executables, it only compiles the executable assembly.

But selecting a C# class library project and selecting Build Project still goes off and builds all these C++ projects.

Upvotes: 0

Views: 1101

Answers (1)

Ameen
Ameen

Reputation: 2586

I don't think you can do that. If project A references project B, then the compiler has to compile both projects in order to compile A. One way out of this would be to include the reference to project B as an assembly, not a project reference. That way, project A depends on the compiled result of project B and the compiler does not need to build it every time. Having an assembly reference though is something I dislike because you have to manage assembly versions and probably check-in binaries into your source control which I dislike as well.

Having said all of this, your build should be incremental. If nothing has changed in the projects from last build, they should be very quick. Perhaps something in your build setup is introducing a defect in such a way that your build is no longer incremental. If you have custom pre/post build steps, examine those to make sure nothing of this sort is happening.

Upvotes: 1

Related Questions