0

I have a solution that one of its projects takes too long to compile and rarely changes. That means that if a developer "ReBuild" the whole solution it will take time (though nothing was changed in this specific project).

I was suggested maybe to add some "pre-build event command line" but how exactly will I check if there is need to compile (I do want it to compile of it was changed)? and - if I can fail it - is this good practice? (in terms of continous integration etc.)

feel free to suggest any other way that I can avoid rebuild if no need even if some developer did mean rebuild for the entire solution.

user1025852
  • 2,684
  • 11
  • 36
  • 58
  • Is there any specific reason you have to rebuild the entire project instead of letting the IDE compile just the files that have modified ? – Radu Chivu Sep 09 '12 at 09:58
  • 1
    I would avoid any tricks that prevent certain parts from building when the function of your IDE explicitly says it will do so. That would only result in situations where you think "Why on earth does it not seem to pick up my changes?". Anyway, just my 2 cents... – Bart Sep 09 '12 at 09:59
  • good question. some of the developers here are use to press "rebuild". This is part of their "clean" flow they want to make sure DLLs are rebuilt again from scratch. they don't care about this specific project cause it is handled by another team on the same source stream. so I don't want them to change their habit. – user1025852 Sep 09 '12 at 10:00
  • 1
    You need to explain your developers that "rebuild" means "rebuild everything from scratch whether it is necessary or not". I'd try to explain that the build system is smart enough to figure out what needs to be rebuilt automatically. I know this kind of "scepticism" very well. Usually, this is the case when devs are used to work with badly set up or otherwise screwed build system... In no case I'd break the build process by purpose, just to keep some old (bad) habits alive. – Paul Michalik Sep 09 '12 at 11:04

1 Answers1

2

VS will usually figure out what needs to be re-built and only compile the appropriate projects. There are some steps you can take though:

  • avoid changes to headers, these trigger re-builds of all translation units that include them
  • use pre-compiled headers
  • use forward declarations instead of includes in header files (where possible)
  • break a large solutions into modular projects that link dynamically with each other
Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625