修改程序集版本和引用 (.NET)
我有一个应用程序 exe 以及文件夹中的 3 个引用的程序集。在VS2010、CLR 4.0中编译。
我想修改所有 4 个程序集的版本以匹配 (1.0.0.0),并修改每个程序集中的参考部分以匹配新版本号。
在应用程序已经在 IDE 之外构建之后,这可能吗?
编辑:
这是场景:我们的 dll 通常安装在具有特定版本的 GAC 中。仅当发布商业产品时版本才会增加。我们有许多自行编写的开发工具,它们使用了 GAC 中安装的一些 dll。这些工具是在某个时刻构建的,并且在代码更改时不会重新构建。 CLR 更喜欢从 GAC 加载程序集而不是本地程序集,因此很多时候我们的工具不使用它们构建时使用的程序集。这是一个大问题,我不知道如何以其他方式解决它。
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 modify 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 Reflector 及其插件 Reflexil;当然,如果程序集已签名,它们将不再一起工作(实际上我认为它们根本无法工作?)。否则你甚至不需要修改我认为的参考文献。
编辑:另外,马克是绝对正确的;无法想象什么情况下绝对需要你这样做,这是相当黑客的。
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.
最简单的选择是简单地重建和重新部署。您可以在配置中执行一些操作(runtime/ assemblyBinding/dependentAssembly/bindingRedirect),但这在这里似乎有点矫枉过正,因为我不确定如何在不重建程序集的情况下更改程序集的版本号,特别是如果它们是签名/强命名的(运行时将检测作恶者)。
这听起来像是在为我工作......
如果 dll 是你的,只需使用正确的版本元重建它们即可。如果它们不是你的,也许就不要跟他们胡闹。
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.