这里的许多人可能都熟悉 Joel Spolsky 最受欢迎的博客文章之一,请先生,我可以有一个链接器,在那里他呼求一种方法来消除对 .NET 框架的依赖因此可以开发和销售独立的应用程序.
Many people here are probably familiar with one of Joel Spolsky most popular blog posts, Please Sir, May I Have a Linker, where he cries out for a way to remove dependencies on the .NET framework so a stand-alone application can be developed and sold.
Jason Zander 当时 Visual Studio 开发团队的回复 和他对这个话题的看法,认为这个话题有点没有实际意义——在运行时修复安全问题的能力(除其他外)是他们主要关心的问题.总的来说,小额开销是值得的.
Jason Zander of the Visual Studio development team, at the time, replied with his views on the topic, arguing that the topic is somewhat moot - the ability to fix security problems in the runtime (among other points) was their chief concern. Overall, the small overhead was worth it.
快进到 2009 年.现在有几个小组声称拥有 C# 链接器.(Jason Zander 甚至自己说实现一个并不需要太多.)我们现在有一个 200-300 mb 的跨平台完整 .NET 3.5 安装程序,而不是可爱的 .NET 1.0 十多万的下载包含适用于 x86、x64 和 ia64 的 .NET 版本.Microsoft 减少运行时大小的建议包括:
Fast forward to 2009. There's a few groups out there now claiming to have C# linkers. (Jason Zander even said himself that it wouldn't take much to implement one.) Instead of the cute, dozen-so meg download of .NET 1.0, we now have a massive 200-300 mb cross-platform complete .NET 3.5 installer that contains versions of .NET for x86, x64, and ia64. Microsoft's suggestions to decrease the runtime size include:
更糟糕的是,据我了解(如果我错了,请纠正我)客户端配置文件甚至没有在 Windows 中注册为安装了 .NET 3.5.这意味着如果在计算机上安装了多个 .NET 3.5 客户端应用程序,则不会互相看到,并且运行时将一次又一次地重新安装!
To make matters worse, as I understand it (please correct me if I'm wrong) the client profile don't even register with windows as having .NET 3.5 installed. This means if multiple .NET 3.5 client applications are installed on the computer, none will see each other and the runtime will be re-installed again and again!
我真的不知道微软在这里是怎么想的.即使假设最坏情况下的安装是针对一个目标平台(例如 x64)并且只需要包含那些库,您仍然会在应用程序上看到超过 60 mb 的开销.甚至最著名的 .NET 应用程序之一 Paint.NET 也充满了 由于大量 .NET 依赖项而导致安装应用程序的困难. 如果他们在分发免费应用程序时遇到问题,那么世界其他地方呢?最后,他们不得不 在他们可以安装自己的应用程序之前,制作一个安装了 Microsoft Installer 3.1、.NET 运行时引导程序和所有其他依赖库的引导程序.
I really don't know what Microsoft is thinking here. Even assuming the worst case install will be for one target platform (eg, x64) and only those libraries need to be included, you're still looking at upwards of 60 mb overhead on your app. Even one of the most well known .NET apps, Paint.NET, was fraught with Difficulties installing the application because of the massive .NET dependencies. If THEY have problems distributing a free app, what about the rest of the world? In the end, they had to Make a bootstrapper that installed Microsoft Installer 3.1, the .NET runtime bootstrapper, and all their other dependent libraires before they could install their own application.
那么怎么样.一个链接器.是否存在任何好的工具 - 或者是一种无需用户安装大量 .NET 运行时就可以简单地构建 C# 应用程序的工具?
So how about it. A linker. Do any good ones exist - or a tool that simply makes it possible to build a C# application without requiring that the user install the massive .NET runtime?
更新:所以,看起来有几个选项:
Update: so, it looks like there's a couple of options:
单声道:
.NET:
看起来 Mono 工具正在使用中;基于 .NET 的工具怎么样?与他们有任何其他经验,还是我们只需要等待 Microsoft 将其 3.5 推出给所有人?想到 .NET 4.0 需要多长时间才能推出,我不寒而栗……
It looks like the Mono tools are getting use; how about the .NET based tools? Any other experience with them, or are we just going to have to wait for Microsoft to push it 3.5 out to everyone? I shudder to think how long it'll take for .NET 4.0 to be put out...
Mono Linker的案例.
我不能过多谈论此处列出的其他软件,但作为 Mono Linker 的作者,我可以知道它做什么和不做什么.
I can't talk much about the other pieces of software that are listed here, but as the author of the Mono Linker, I can tell what it does and what it does not.
Mono 链接器只是一个托管链接器,因此根据定义,它需要程序集,并删除程序运行不需要的内容.它不会将所有程序集合并在一起,也不会用它们制作本机程序.
The Mono Linker is only a managed linker, so by definition, it takes assemblies, and removes what's not necessary for a program to run. It doesn't merge assemblies all together, and it doesn't make a native program out of them.
有一个 ILMerge 的 Mono.Merge 克隆,但它并不完整,它的作者也没有维护它.为了生成包含 Mono 运行时和程序集的本机程序,Mono 提供了 mkbundle 工具.
There's a Mono.Merge clone of ILMerge, but it's not complete, and its author is not maintaining it. To generate a native program containing both the Mono runtime and assemblies, Mono provides the mkbundle tool.
此外,由于它只是一个托管工具,它正在更改程序集,如果您为其提供强命名程序集,并且您没有私钥来签名它们,那么您将在运行这些程序集时遇到麻烦.
Also, as it is only a managed tool, which is altering assemblies, if you give it strong named assemblies, and that you don't have the private keys to sign them back, you'll have troubles running those assemblies.
我写了几篇关于链接器的博文:
I wrote a couple of blog posts about the linker:
关于我们使用 Linker 的体验.链接器目前用于 Mono 项目的两个部分.它用于生成我们分发的程序集,供人们嵌入我们的 C# 编译器 Mono.CSharp.dll.您可以在 PDC 上观看 Miguel 的演示,其中描述了我们如何做到这一点.它非常简单,它是 Linker 的基本用法,它是一个可定制的工具,并且很容易为其编写自定义步骤.
About our experience with the Linker. The Linker is currently used in two parts of the Mono project. It's used to generate the assembly that we distribute for people to embed our C# compiler, Mono.CSharp.dll. You can watch Miguel's presentation at the PDC, which describes how we do that. It's pretty straightforward, and it's a basic usage of the Linker, which is a customizable tool, and it's pretty easy to write custom steps for it.
链接器的一个更复杂的用途是我们创建我们的 Moonlight 程序集.Moonlight 是我们的 Silverlight 实现,程序集是桌面程序集的子集.因此,我们链接我们的桌面程序集以减小它们的大小,并使用自定义步骤,我们正在转换公共 API 以匹配 Silverlight 的.
A more complex use of the Linker is the way we create our Moonlight assemblies. Moonlight being our implementation of Silverlight, the assemblies are a subset of the desktop assemblies. So we link our desktop assemblies to reduce their sizes, and using custom steps, we're transforming the public API to match Silverlight's.
是的,链接器有一些非常粗糙的边缘,例如命令行界面,或者您必须真正知道自己在做什么这一事实,或者您最终可能会得到一些奇怪的程序集,但所有总而言之,它对我们非常有效.
So yeah, the Linker has some pretty rough edges, such as the command line interface for instance, or the fact that you have to really know what you're doing, or you may end up with some weird assemblies, but all in all, it works really well for us.
这篇关于.NET 应用程序的链接器状态(又名“请先生,我可以有一个链接器"2009 年版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!