Dependent Assemblies Not Copying To Output Directory Because of Version Number Of Dependent Assembly
On the project I work on we encountered an odd error. This was caused by some funny manipulation of version numbers because of some odd branching we did. We have resolved the issue but I'm curious if I can get an explanation about the behavior msbuild is exhibiting. The same behavior was observed when building using Nant and Visual Studio 2008.
The Setup: Version numbers for assemblies are controlled by a common file that is linked into the properties of all the assemblies. This is done to keep them all in synchronization with each other. However, there are some assemblies we have that are pre-compiled and are only occasionally built. They are used for serialization and are partly generated from XSD's. Since serialization doesn't change that often they obviously don't need to be rebuilt that often.
The Situation: The version number in the linked file was updated. After this happened the pre-compiled assemblies were rebuilt because serialization changed. After this happened it was decided that a lower version number was needed. The common linked file was updated again, but to have a lower version number than it did before.
The Problem: After this last update to the version number the build stopped copying some of the dlls to the output directory of one specific project stopped working properly. We'll call this project A. A has a dependency on assembly B and assembly B has a dependency on assembly C and assembly C depends upon one of the pre-compiled dlls. This seems like a long chain, but this chain is key. The other key fact is that A does not have a direct reference to C. When A is built before lowering the version number C is copied into the output directory. This issue is, after the version number being lowered C no longer is copied into the outpu开发者_如何学Ct directory. There were three ways this problem could be corrected. If any of these changes are made then C is copied to the output directory properly.
- Add a direct reference to C in A's project.
- The version number is changed back or made to be higher than it was when the pre-compiled dlls were built.
- Rebuild the pre-built assemblies with the version number update.
The third option was how the issue was resolved. My question is is this a bug with msbuild or the intended behavior? What would the purpose of this behavior be? Why instead of creating an error does it just not copy the dll to the output directory?
producing a newer assembly with a lower version is perhaps questionable. what happens when you need to make a newer one again?
basically if you make a new version of something, increase the version number; problem solved as you found in your second solution.
in answer to your question - it is intended behaviour that files with lower or same version numbers do not overwrite others
精彩评论