Modify Assembly Version and References (.NET)
I have an application exe plus 3 referenced assemblies in a folder. Compiled in VS2010, CLR 4.0.
I'd like to modify the version of all 4 assemblies to match (1.0.0.0) and also m开发者_如何转开发odify the reference section in each of those assemblies to match the new version number.
Is that possible after the application was already build outside the IDE?
EDIT:
Here is the scenario: Our dlls are often installed in the GAC with a specific version. The version is only incremented when commercial products are released. We have many self written development tools that use some of those dlls that are installed in the GAC. The tools are build at a certain point and not rebuild when the code has changed. The CLR prefers to load the assembly from GAC though instead of the local assemblies, so many times our tools do not use the assemblies that they were build with. Thats a huge problem and I don't see how it could be solved otherwise.
Use Reflector and its plugin Reflexil; of course, if the assemblies are signed they won't work together anymore (actually I think they won't work at all?). Otherwise you won't even need to modify the references I think.
Edit: also, Marc is absolutely right; can't imagine what scenario would absolutely require you to do this, it's quite hackish.
The simplest option is to simply rebuild and redeploy. There are things you can do in config (runtime/assemblyBinding/dependentAssembly/bindingRedirect), but that seems overkill here, since I'm not sure how you would go about changing the version numbers of the assemblies without rebuilding them, especially if they are signed/strong-named (the runtime will detect evil-doers).
It sounds like making work to me...
If the dlls are yours, just rebuild them with the right version meta. If they aren't yours, perhaps don't monkey with them.
Sounds like you need a publisher policy or a binding redirect. This will enable your assemblies to always use the latest version, or to use a specific version of a referenced assembly.
精彩评论