Visual Studio keeps building everything

2019-01-12 09:25发布

I have a large .sln file with many projects.

I just made a change in project A and it builds nine other projects that project A references, but that had no code change.

Is there a trick to speed this process up?

6条回答
干净又极端
2楼-- · 2019-01-12 10:09

This happens when a project has a file that doesn't really exist.
The project can't determine if the file was changed (because it's not there) so it rebuilds.

Simply look at all the files in the project, and search for the one that doesn't have an expandable arrow near it.

查看更多
霸刀☆藐视天下
3楼-- · 2019-01-12 10:11

Make sure your project dependencies are correct. Right click on the project and go to "Project Dependencies." Make sure that each project only depends on the minimal set of other projects that are needed to link.

查看更多
闹够了就滚
4楼-- · 2019-01-12 10:20

Another thing to look for, because it just happened to me, is that if you synchronise your view using ClearCase while your solution is open and some of your code was updated by the synch, it sometimes sets the timestamps incorrectly on the files, so it keeps thinking your source files have been modified and compiling your project every time.

To fix this I had to close the solution and reopen it again, and it behaved as expected.

查看更多
爷的心禁止访问
5楼-- · 2019-01-12 10:24

Divide and conquer: Limit the amount of build time that goes on in your solution by creating additional solutions that contain logical subsets of projects you're working on. This limits your scope and will speed up builds.

See the The Partitioned Single Solution Model in this MSDN article: http://msdn.microsoft.com/en-us/library/ee817674.aspx

Key quote from the article:

Separate solution files allow you to work on smaller subsystems within your overall system 
but retain the key benefits of project references. Within each subsolution file, 
project references are used between constituent projects.
查看更多
倾城 Initia
6楼-- · 2019-01-12 10:28

Change the build output verbosity to detailed and see what it says at the top. In my case, it told me the project wasn't up to date because of a file that was missing.

查看更多
可以哭但决不认输i
7楼-- · 2019-01-12 10:32

Selecting 'build only' when right-clicking the project A should do the trick. I am not sure if there is a way to keep it from building referenced projects as well when building the solution (which is what the standard 'build' command does).

查看更多
登录 后发表回答