减少 Mono 运行时大小
Reduce Mono runtime size
我已经在 Amazon Linux 实例上从源代码编译了单声道 运行-time。编译后'lib'和'bin'目录共计320MB。我想让它尽可能小。我可以从那里删除什么(如果有的话)以尽可能多地节省 space。
首先,我将从这里开始:
How to make a smaller Mono install / Small Footprint
我自己:
我没有删除二进制文件或 're-link' 程序集,但我确实在配置时关闭了一堆选项,当然,使用 4.x 版本的单声道你的里程可能会有所不同:
我的 OS-X/Linux 单声道目录的磁盘使用量约为 174MB,其中 GAC 中的磁盘使用量约为 60MB (~~/lib/mono/GAC)。如果您不使用 GAC 来解析程序集(我不这样做),那么完整的 4.5 框架还剩下大约 110MB。框架中有很多我个人从未使用过的项目,但我从来没有发现值得为它创建一个删除列表以尝试再节省 10-30MB...
仅供参考:
我的'small'OS-X配置:
./autogen.sh \
--with-tls=posix \
--enable-nls=no \
--with-mcs-docs=no \
--with-profile2=no \
--with-profile4=no \
--with-profile4_5=yes \
--with-moonlight=no \
--host=i386-apple-darwin10 \
--with-glib=embedded \
--prefix=${PlayInstallPath}
我的'small'Linux配置:
./autogen.sh \
--with-mcs-docs=no \
--with-profile2=no \
--with-profile4=no \
--with-profile4_5=yes \
--with-moonlight=no \
--prefix=${PlayInstallPath}
评论更新:
Can I get rid of the 2.0 directory - I will always be targeting 4.5
framework. How do I go about using only the 4.5 directory and get rid
of the GAC? Can I just copy the proper dlls there?
运行 没有 GAC:
如果您查看像 Xamarin Studio/Mono Develop 这样的应用程序,它使用 MSBuild 来解析程序集位置而不是 GAC。 GAC 并不是真正需要的,在新的 MS .Net Core 部署模型中,app/service/Docker/etc 所需的所有 .Net 程序集都只是复制到相同的部署目录,版本控制问题不是问题,因为您可以回滚目录更改以恢复到先前的构建或只是 sym-link 到不同的目录以更改为新版本,等等......如果你这样做是为了生产 staging/version,请与你的 DevOps 联系以坐标 who/what/when/where...
在 Mono 中,您可以使用 MONO_PATH 跳过 GAC 并直接进入 lib 目录,而这 不是 最佳实践,它适用于 我们的我们正在做的事情的环境(你的里程会因应用程序类型而异),但阅读以下单声道links来理解优缺点以及您应该如何做:
http://www.mono-project.com/archived/best_practices/#monopath
并且:
http://www.mono-project.com/docs/getting-started/application-deployment/
至于 net_2_0 目录,我从来没有得到一个,因为我在 autogen/configure 步骤中通过“--with-profile2=no”关闭了该配置文件。
我已经在 Amazon Linux 实例上从源代码编译了单声道 运行-time。编译后'lib'和'bin'目录共计320MB。我想让它尽可能小。我可以从那里删除什么(如果有的话)以尽可能多地节省 space。
首先,我将从这里开始:
How to make a smaller Mono install / Small Footprint
我自己:
我没有删除二进制文件或 're-link' 程序集,但我确实在配置时关闭了一堆选项,当然,使用 4.x 版本的单声道你的里程可能会有所不同:
我的 OS-X/Linux 单声道目录的磁盘使用量约为 174MB,其中 GAC 中的磁盘使用量约为 60MB (~~/lib/mono/GAC)。如果您不使用 GAC 来解析程序集(我不这样做),那么完整的 4.5 框架还剩下大约 110MB。框架中有很多我个人从未使用过的项目,但我从来没有发现值得为它创建一个删除列表以尝试再节省 10-30MB...
仅供参考:
我的'small'OS-X配置:
./autogen.sh \
--with-tls=posix \
--enable-nls=no \
--with-mcs-docs=no \
--with-profile2=no \
--with-profile4=no \
--with-profile4_5=yes \
--with-moonlight=no \
--host=i386-apple-darwin10 \
--with-glib=embedded \
--prefix=${PlayInstallPath}
我的'small'Linux配置:
./autogen.sh \
--with-mcs-docs=no \
--with-profile2=no \
--with-profile4=no \
--with-profile4_5=yes \
--with-moonlight=no \
--prefix=${PlayInstallPath}
评论更新:
Can I get rid of the 2.0 directory - I will always be targeting 4.5 framework. How do I go about using only the 4.5 directory and get rid of the GAC? Can I just copy the proper dlls there?
运行 没有 GAC:
如果您查看像 Xamarin Studio/Mono Develop 这样的应用程序,它使用 MSBuild 来解析程序集位置而不是 GAC。 GAC 并不是真正需要的,在新的 MS .Net Core 部署模型中,app/service/Docker/etc 所需的所有 .Net 程序集都只是复制到相同的部署目录,版本控制问题不是问题,因为您可以回滚目录更改以恢复到先前的构建或只是 sym-link 到不同的目录以更改为新版本,等等......如果你这样做是为了生产 staging/version,请与你的 DevOps 联系以坐标 who/what/when/where...
在 Mono 中,您可以使用 MONO_PATH 跳过 GAC 并直接进入 lib 目录,而这 不是 最佳实践,它适用于 我们的我们正在做的事情的环境(你的里程会因应用程序类型而异),但阅读以下单声道links来理解优缺点以及您应该如何做:
http://www.mono-project.com/archived/best_practices/#monopath
并且:
http://www.mono-project.com/docs/getting-started/application-deployment/
至于 net_2_0 目录,我从来没有得到一个,因为我在 autogen/configure 步骤中通过“--with-profile2=no”关闭了该配置文件。