views:

51

answers:

2

Hi all,

Is there any way that I can prevent a designer class from being rebuilt when running my project?

The designer class is a webservice reference with over 30000 lines of code and appears to be being rebuilt almost every time I run my project. (Which obviously takes quite some time)

Is there some explicit way I can prevent Visual Studio 2010 from rebuilding this class each time I run the project?

+3  A: 

One obvious suggestion: put it in a different project, as a class library. Visual Studio should detect that nothing in that project has changed, and avoid rebuilding it.

I realise this is somewhat ugly, but it may be a reasonably practical approach. Of course if there are other types in the project which are related to the web service and which also don't change much, you could add them into the same project.

EDIT: While I don't think there's anything in the web service properties box about this, you might want to check it... and check whether the designer file itself is being regenerated. If for some reason it's fetching the metadata on every build (do you have any custom build rules?) that would quite possibly be the problem.

Jon Skeet
Yeah obviously this is something I have considered but given this is a TINY little usercontrol I am coding I am hoping to avoid doing that. If there is no explicit way of doing this I will go ahead and take this approach but surely there has to be an attribute I can set somewhere?
Maxim Gershkovich
@Maxim: I see no reason to assume that. I'm surprised it's taking a really long time to rebuild it, as I *thought* that there was a degree of incremental compilation within Visual Studio - but if that isn't the case, I doubt that there'd be a way of turning it on. I'm intrigued by your "almost" though - is it definitely not being rebuilt on *every* build?
Jon Skeet
Visual Studio has always been really good in this department (and appeared to be smart enough to not rebuild files that were not modified) Basically I run the project, it runs a huge compile (takes a minute plus). I stop the project and make no changes and rerun, it runs without full compile and starts straight away. I now stop the project and add a line to my form (which contains like 10 lines of code total) and the project takes a minute plus to recompile and run.
Maxim Gershkovich
PS: I have a feeling that the designer is modifying the file in between builds (as you suggested) and causing the file to be rebuilt. I may test this in future.PSS: I have no custom build rules.
Maxim Gershkovich
@Maxim: I would definitely check whether the file is being changed as your first port of call. It should be easy enough to do, and could save a lot of time.
Jon Skeet
A: 

Have a look at the "Configuration Manager". It's under the menu item: Build -> Configuration Manager... It allows you explicitly disable which projects are build depending on the solution configuration.

Another option is to unload the project for the solution.

Alastair Pitts
I don't think the problem is rebuilding the project - it's that the OP wants incremental compilation *within* the project, as a large file hasn't changed.
Jon Skeet
Ooooooo, I see.
Alastair Pitts