views:

438

answers:

5

Is there a way to find out the reason why a project is being rebuilt each time a Build Selection operation is issued in VS 2008?

I've tried to even remove all dependencies from the Build\Configuration Manager (unchecked the build column for all assemblies, but the one in question).

I get the same result: the assembly is rebuilt each time.

I have to mention that all the dependencies are built in the same directory (there is a common Output Directory).

Actually it's not very clear to me what is the VS/MSBuild algorithm to decide whether a project should be rebuilt or not. Does it check to see whether there are dependencies (files/assemblies) that have the Last Access NTFS timestamp newer than the one on the assembly in question? Maybe I could try to search for the "offending" file this way.

A: 

I am not 100% sure, but it appears projects with any warnings will always be rebuilt.

leppie
Hmm, that's strange, because the same project on a different branch (not very much different as they are being merged once a month), is being rebuilt only when changes have taken place. It's true that both of them have many-many warnings though.
Florin Sabau
No, it's not true. Build process doesn't depend on previously found warnings.
Kamarey
+1  A: 

Is there a circular dependency between different modules/projects in your application?

Greg D
No, no circular dependencies, as that is not supported by the compiler. But I do have a service reference to a WCF service which also has a reference to the same parent dll (only the reference is to the compiled assembly from a DLLs directory, not the project reference).Still, the same references are in the other branch which compile just fine. The problem might be related to this though, as the problem has appeared aprox. de same time the service references was added.
Florin Sabau
Actually, now that I double checked, the reference from the WCF service is directly to the solution project (not a compiled dll). But the reverse reference is still a service reference which is an "offline" kind of a reference. It's not updated automatically. So I would suspect this is not a problem. Again, the project from the other branch, which also has this reference, doesn't expose the problem.
Florin Sabau
+3  A: 

Do you have a Prebuild action defined that updates some of your input files? Also a custom build step that is always triggerd might be the reason.

What kind of project type do you have?

Frank Bollack
No pre build events on the project in question. But I do have pre build events on some of the dependencies.The type of the project is "Class Library".
Florin Sabau
+1  A: 

If you are modifying the AssemblyInfo.cs with an updated AssemblyFileVersion (As I do with Cruise Control .Net) for example I've found that it forces a rebuild.

Ryu
We have here a single AssemblyVersion.cs file that is linked in every project in the solution. It doesn't change and it is not copied in a prebuild event, so it shouldn't trigger the recompilation. Thanks for your answer.
Florin Sabau
Yes I have the same configuration with a single AssemblyInfo.cs as well. On the build box I do change this file and because of this it seems to force a rebuild
Ryu
Well, on the build box it always rebuilds because there are no assemblies left over between builds and I think it is desirable to be that way. But on the DEV box it is really annoying to wait for the build even if it is not needed.
Florin Sabau
A: 

I have not found the root cause of the problem, but have found a way to get rid of the effects:

GetLatestVersion (with the "overwrite existing" option).

Everything is ok now.

One more thing that I found out, unfortunately after I have overwritten the local project files with the Workspace version: there is an option in Tools-Options-Projects and Solution-Build and Run-MSBuild project build output verbosity.

This option is set to Minimal by default. If set on Detailed or Diagnostic will log a lot of interesting messages in the Output Window when compiling a project. It may have given me pointers as to why the project was being compiled each time.

Florin Sabau