Why do my projects build when there are no changes?
I've got many C# (Visual Studio 2008) projects and a few of them are updating the ass开发者_如何学JAVAembly even when there have been no changes (even when I choose Build and not Rebuild). Most of my projects don't do this, its just the odd few.
I have yet to find any difference between the projects and wondered if anyone had any ideas what could be influencing it. To be clear, I've not made any code changes before building but the assembly is still being recreated when I run the Build command within Visual Studio.
I'm sorry I can't provide any further details but please let me know if there is anything else that I can check that may shed some light.
Can anyone help? I've been tearing my hair out for a while on this.
Thanks, Alan
Actually Hans' now-deleted answer pointed me to the right direction. Cranking up MSBuild's verbosity to diagnostic told me that VS considered a project always out of date because one file had "Copy to output directory" set to "Copy always". And the other projects followed from that because they depended on that project an noticed that the newly-built DLL was newer than one of their own output files.
Changing "Copy to output directory" to "Copy if newer" resolved that.
There is something called project dependencies.
When one of your project depends on one or more other projects and you build it the other projects that your projects depends on will also begin to be built (if needed). Additionally if the dependencies have changed then the projects dependent on them will always be rebuilt.
You can Right Click on Solution and select Project Build Order to bring up a window which explains the order in which projects are built and the dependencies for each project.
I didn't get to the bottom of this one and ended up reconstructing one of the projects. It turned out that it was all stemming from this one project that was always rebuilding.
I think it had something to do with the embedded resources being rebuilt every time.
Sorry I don't have a definitive answer on this one. Thanks to RobV too for the useful information.
Alan
精彩评论