Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force VS 2010 to skip "builds" of projects which haven't changed?

Our product's solution has more than 100+ projects (500+ksloc of production code). Most of them are C# projects but we also have few using C++/CLI to bridge communication with native code.

Rebuilding the whole solution takes several minutes. That's fine. If I want to rebuilt the solution I expect that it will really take some time. What is not fine is time needed to build solution after full rebuild. Imagine I used full rebuild and now without doing any changes to to the solution I press Build (F6 or Ctrl+Shift+B). Why it takes 35s if there was no change? In output I see that it started "building" of each project - it doesn't perform real build but it does something which consumes significant amount of time.

That 35s delay is pain in the ass. Yes I can improve the time by not using build solution but only build project (Shift+F6). If I run build project on particular test project I'm currently working on it will take "only" 8+s. It requires me to run project build on correct project (the test project to ensure dependent tested code is build as well). At least ReSharper test runner correctly recognizes that only this single project must be build and rerunning test usually contains only 8+s compilation. My current coding Kata is: don't touch Ctrl+Shift+B.

The test project build will take 8s even if I don't do any changes. The reason why it takes 8s is because it also "builds" dependencies = in my case it "builds" more than 20 projects but I made changes only to unit test or single dependency! I don't want it to touch other projects.

Is there a way to simply tell VS to build only projects where some changes were done and projects which are dependent on changed ones (preferably this part as another build option)? I worry you will tell me that it is exactly what VS is doing but in MS way ...

I want to improve my TDD experience and reduce the time of compilation (in TDD the compilation can happen twice per minute).

To make this even more frustrated I'm working in a team where most of developers used to work on Java projects prior to joining this one. So you can imagine how they are pissed off when they must use VS in contrast to full incremental compilation in Java. I don't require incremental compilation of classes. I expect working incremental compilation of solutions. Especially in product like VS 2010 Ultimate which costs several thousands dollars.

I really don't want to get answers like:

  • Make a separate solution
  • Unload projects you don't need
  • etc.

I can read those answers here. Those are not acceptable solutions. We're not paying for VS to do such compromises.

like image 572
Ladislav Mrnka Avatar asked Dec 06 '11 10:12

Ladislav Mrnka


People also ask

Why is Visual Studio rebuilding every time?

The problem Sometimes, Visual Studio will always rebuild projects, even though they have recently been built and there are no changes. If you build , and then run the project will build. If you haven't disabled the “projects out of date”-dialog, it will pop up and ask you to rebuild.

How do I stop an ongoing build in Visual Studio?

You can hit Ctrl + Break on the keyboard to cancel/stop a build that is currently in progress.

How do I clean up and build a project in Visual Studio?

To build, rebuild, or clean an entire solutionChoose Build All to compile the files and components within the project that have changed since the most recent build. Choose Rebuild All to "clean" the solution and then builds all project files and components. Choose Clean All to delete any intermediate and output files.

How do I change the build order on a project?

In order to set the Build order for your Solution, right-click on the Solution in Solution Explorer and Select Project Build Order: Your Project Dependencies should be set correctly which is used to determine the Build order by Visual Studio.


2 Answers

By default Visual Studio will always perform build of every project in your solutuion when you run a single project. Even if that project doesn't depend on every other project in your solution.

Go to Tools | Options | Projects and Solutions | Build and Run and check the box "Only build startup projects and dependencies on Run". Since now when run your project (F5 key), Visual Studio will only build your startup project and the those projects in your solution that it depends on.

like image 64
Dmitriy Konovalov Avatar answered Oct 20 '22 04:10

Dmitriy Konovalov


Is there a way to simply tell VS to build only projects where some changes were done and projects which are dependent on changed ones (preferably this part as another build option)? I worry you will tell me that it is exactly what VS is doing but in MS way ...

Not really (you understand it already).

You are talking about a "build system". MSVS is not that. It is an IDE, which happens to permit you to organize your assets into projects-and-solutions, and yes, to "build". But, it is not a build system. It will never be a build system (long story, but a very different technology is required).

In contrast, MSVS is an IDE for accelerated iterative development, including the "debugging" cycle (e.g., "step-into" and "step-over" in the debbugger during system run). That's where MSVS "shines".

It does not, and will never, "shine" as a build system. That's not what it was created to do. And, this will likely never change (long story, even Microsoft will likely agree).

I'm not trying to be cute, and I sincerely apologize for delivering this news. This answer hurts me too.

I expect working incremental compilation of solutions. Especially in product like VS 2010 Ultimate which costs several thousands dollars.

MSVS is an IDE for interactive debugging/development, and not a build system (see above). So, you are measuring it in a product scenario for which it was not designed, and in which it will likely never function as you desire.

I really don't want to get answers like:

  • Make a separate solution
  • Unload projects you don't need
  • etc.

I can read those answers . Those are not acceptable solutions. We're not paying for VS to do such compromises.

Your expectations are reasonable. I want them too. However, MSVS is not a product that will ever deliver that.

Again, I'm not trying to be "cute". If you are willing to invest in a "build system", you may find value in using something like CMake to manage your configurations and export Makefiles (or something) to perform your "real" builds, but to also "export" *.vcproj and *.sln files for when you want to do work iteratively and interactively within the MSVS IDE.

EDIT: Rather, what you want is a SSD (solid-state-disk) for your build workspace to get a 10x improvement-in-speed, or a RAM disk for a 100x improvement-in-speed for builds (not kidding, 64MB RAM on an LGA2011 socket gives you a 32MB RAM disk, which is what we use.)

like image 8
charley Avatar answered Oct 20 '22 02:10

charley