Strange VS2010 build glitch occurs in my solution
Asked Answered
E

2

0

I've discovered that it is rare for Visual Studio behave like this. One of the comments was this might be because the projects were upgraded from VS2008.

To get specific. Say there's a dependency beween projects where A depends on B, B depends on C, and C depends on D.

A<--B<--C<--D.

Now say there's an error in A, but B,C,and D compiled correctly.

What happens next for me is that VS will compile all four projects every time I try to compile A.

Command: right-click on project A, select Build.

same behaviour from menu: Build / Build A


Is there a way to ensure that Visual Studio only rebuilds a dependent projects when there are changes in those proejcts? Currently Visual Studio rebuilds all dependencies.

I noticed that the suggestion on the link below was to partition the solution into logical groups (and then reference .dlls directly I suppose). If this is the best way forward, is it to have each project build to a common .\bin folder, and then reference from there?

related question: Visual studio keeps building everything

It'd be awesome if I could keep one big solution file.

UPDATE:

  • discovered a warning in verbose build mode described here: http://support.microsoft.com/kb/2516078 It doesn't seem to be related though. I'm still going to fix this just-in-case. (NOW FIXED by re-referencing projects + path hints by hand using $(VAR) environment variables)

  • pointed a desk fan directly at laptop. CPU was being throttled because of overheating.

  • went through every project and switched off auto serialization (found in the project properties / build screen)

  • increased the maximum number of parallel builds in tools / options / Build and Run. I didn't think this would help given that it is just a laptop with two cores, but it did.

  • seeing 'Previously built successfully'... so looks like desired behaviour is often occuring (still investigating). Situation is much better now though.

  • still going through verbose build logs and tidying things up.

Edouard answered 1/8, 2011 at 16:45 Comment(13)
What version of Visual Studio are you using? More importantly, please give an example of what doesn't work for you, since, for most people, it does work.Surge
My visual studio doesn't rebuild everything. Only those changed or have changed dependencies builds.Bev
I've experienced this problem when upgrading sln and project files from previous VS versions. After re-creating the solution and projects, I've always had it go away.Overact
It amazes me to find people who can believe things like, "Visual Studio builds always rebuild all dependencies". How could this be true and not have hundreds of thousands of developers not be furious with Microsoft?Surge
@Stephen Cleary: many projects were migrated from VS 2008. I wonder if that's the problem. I'll try it out. Thanks.Edouard
@John Saunders: VS 2010 ProfessionalEdouard
@sgtz: Yeah, you're doing something wrong.Surge
@John Saunders: I'm not asserting that all developers are experiencing this issue. Just that I am for some reason. I think MS did a great job on VS. Just want to get past this glitch though.Edouard
@sgtz: perhaps you should edit your question to reflect this. "rationalise the build process" sounds like you believe the process is irrational.Surge
@John Saunders: fair comment. See where you are comming from now. I'll do that.Edouard
You sill didn't put it in the form of "when I do this, Visual Studio does that; how do I make it do the other". Up to you, though; note that I didn't downvote the question.Surge
@John Saunders: thanks. I tried to take your comments on board. Agree that the question could be improved like you suggest.Edouard
I suggest you first do a full Rebuild of the entire solution then try to build A and see if anything else gets built. If so, then set the build verbosity to "Verbose" and try again - read the Output window to see why the other projects are being built.Surge
G
1

I don't know the cause of the glitch. When I press F5, VS only seems to build what needs to be built.

But I have a suggestion: make good use of the "Unload project" function. If your solution contains projects only because you reference them, but those projects themselves don't depend on anything else in your solution, then once they've been built you can unload them.

For example, this is my current situation:

I'm working on the UI for my project. I have a solution just for my UI.

I need to reference some libraries being developed by other team members, but I rarely make any changes to those libraries myself.

So my solution contains about 15 projects, but only 10 of them are mine. The other 5, the libraries I reference, don't need to be loaded unless I need to see or change that code. So I just keep them "unloaded".

Every day or two I "reload" them, get latest changes from source control, rebuild, and then unload them again.

I also unload some of my own projects which I rarely need to change, such as my framework library.

This keeps my solution nimble because when I build the solution, only about half the code is actually built. It also speeds up searches and keeps the Solution Explorer less cluttered.

Gayla answered 1/8, 2011 at 17:44 Comment(4)
are you referencing the .dll of these unloaded projects? I tend to reference by project.Edouard
@sgtz: Heck no. I'm talking about having the actual code projects in my solution and referencing them. When you unload them, they're still referenced, but they won't be rebuilt.Gayla
I thought so. When I tried that, the projects that referenced them wouldn't compile. I must be missing something.Edouard
@sgtz: Make sure you're doing "unload project", not "remove". And make sure you've done a full build before you unload them.Gayla
D
4

You probably want to check the following option:

[x] Only build startup projects and dependencies on Run

under Tools -> Options -> Projects and Solutions -> Build and Run.

enter image description here

Downtoearth answered 1/8, 2011 at 16:51 Comment(1)
tried that check box, but VS still labours on unneccessary builds unfortunately.Edouard
G
1

I don't know the cause of the glitch. When I press F5, VS only seems to build what needs to be built.

But I have a suggestion: make good use of the "Unload project" function. If your solution contains projects only because you reference them, but those projects themselves don't depend on anything else in your solution, then once they've been built you can unload them.

For example, this is my current situation:

I'm working on the UI for my project. I have a solution just for my UI.

I need to reference some libraries being developed by other team members, but I rarely make any changes to those libraries myself.

So my solution contains about 15 projects, but only 10 of them are mine. The other 5, the libraries I reference, don't need to be loaded unless I need to see or change that code. So I just keep them "unloaded".

Every day or two I "reload" them, get latest changes from source control, rebuild, and then unload them again.

I also unload some of my own projects which I rarely need to change, such as my framework library.

This keeps my solution nimble because when I build the solution, only about half the code is actually built. It also speeds up searches and keeps the Solution Explorer less cluttered.

Gayla answered 1/8, 2011 at 17:44 Comment(4)
are you referencing the .dll of these unloaded projects? I tend to reference by project.Edouard
@sgtz: Heck no. I'm talking about having the actual code projects in my solution and referencing them. When you unload them, they're still referenced, but they won't be rebuilt.Gayla
I thought so. When I tried that, the projects that referenced them wouldn't compile. I must be missing something.Edouard
@sgtz: Make sure you're doing "unload project", not "remove". And make sure you've done a full build before you unload them.Gayla

© 2022 - 2024 — McMap. All rights reserved.