views:

949

answers:

3

How do I set up MS Visual Studio 2005 project dependencies such that making a change in a higher level project does not force a recompile of all other projects it depends on.

If I have 5 dll projects, which are related in various ways... Under the 'Project'->'Dependencies' I have identified the next project down, but only down one level. When I make a small change to the higher project, a select 'Build'->'Build myLib' the lower project is also recompiled... If I specify all dependencies, then all dependent projects are also recompiled... which isn't right, is it?

If I remove the explicit dependency, the lower project won't get rebuilt, even if it should be (which is as i would expect).

What if I have several levels of dependency (A depends on B depends on C etc)?

+1  A: 

What if I have several levels of dependency (A depends on B depends on C etc)?

Select project A from the dropdown, add B as a dependency. Similarly, for B, select C as a dependency.

dirkgently
Thats's how I have it now... As I work in the higher project, it keeps recompiling the lower dependency even though i haven't changed it.
Krakkos
Maybe your clock was in the future when you made some changes before. Try to re-checkout your project from your source code management system, or find a command somewhere to reset all the dates on your files.
Brian R. Bondy
I think all timestamps should be OK... I can rebuild the entire solution, changed project A, then hit build project A, and project B appears to get compiled also. (at least, the same warnings that were output during compilation of B are output again.
Krakkos
A: 

How do I set up MS Visual Studio 2005 project dependencies such that making a change in a higher level project does not force a recompile of all other projects it depends on.

I think you mean:

How do I set up MS Visual Studio 2005 project dependencies such that making a change in a higher level project does not force a recompile of all other projects that depend, possibly indirectly, on it?

I think you are using terms like "higher" and "lower" in the opposite sense than I would -- for a pair of projects, I think of the "lower" project as being the one that depends on the other one. It could be that your "mental diagram" is simply vertically flipped with respect to mine, which is fine; or it could be that you have misinterpreted what the Project Dependencies box is asking for, which is not. It is asking for the list of projects that the named project in the drop-down list above directly depends on, namely those projects that must be up-to-date (which possibly requires rebuilding) before the named project can be built.

So: could you please clarify in what sense you intend "higher" and "lower" to be taken.

What VC++ should (and I'm certain does) do when you ask to build some project X is check whether all projects that X depends on, either directly or indirectly, are up-to-date, and build any that are not. When this building occurs, each project is always built after any projects that it depends on, either directly or indirectly. Note that projects may require rebuilding even if they are not changed themselves -- e.g. if X depends on Y and Y depends on Z, then changing Z and requesting X to be built entails first building Z, then Y (which was not changed), then X. If there are even "lower" (in my sense) projects that depend on X, they will not be built when you request X to be built.

j_random_hacker
Thanks for that... yes, my 'mental diagram' is vertically flipped wrt yours.. :) If A DEPENDS ON B, I was saying it is higher up. no matter :) as long as we're clear.As for what VC++ does, I agree with your understanding in your last sentence... "if X depends on Y and Y depends on Z, then changing Z and requesting X to be built entails first building Z, then Y (which was not changed), then X."
Krakkos
I think your mental diagram of dependency is similar to a diagram of inheritance, no? Which I would visualise as flowing top to bottom with base classes at the top..never really considered it to be upside down . :)
Krakkos
A: 

I have my project dependencies set for only level anyway:

  • Project A depends on Library B
  • Project A depends on Library C

However, library B also uses library C, but I don't have that set as a dependency. This seems to work fine.

Are you changing header files? Certainly - if you change headers, then any project dependent on that header will have to be rebuilt whether you have Project Dependencies set up or not.

Steve Folly
I am changing headers and source in project A in your system.When I rebuild A, the compiler prints out warnings about certain bits of code in B. I would expect it to ignore B, as it hasn't changed.
Krakkos
@Krakkos - which warnings are displayed?I had an odd situation where I had a couple of .cpp files in two projects at once (the drag-n-drop to add files went a bit awry). Just a thought.
Steve Folly
@Steve: Have to -1 you sorry as you really need to have C listed as a dependency of B as well. What if you start working on a new project, D, which depends on B only -- then a change to C should force a rebuild of B, but won't. Cue hard-to-find bugs. Whenever you neglect the true dependency relationship, you make problems for yourself down the road.
j_random_hacker