如何在安装结束时运行 nGen (MSI)?
我想在安装结束时执行 nGen,只是为了提高应用程序首次启动的感知性能。 我怎么能这么做呢? 有一些最佳实践吗? 我能否确定 nGen 始终与 .NET Framework 一起安装?
谢谢!
I would like to execute nGen at the end of my installation simply to improve the perceived performance of the first startup of my application. How could I do that? Is there are some best practices? Can I be sure that nGen is always installed with .NET Framework?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用自定义安装程序操作生成程序集。 以下链接更详细地解释了这一点:
http://www.dotnetperls.com/ngen
我可以还记得有关 Paint.NET 安装程序的精彩讨论(其中包括 .NET Framework 引导、预 JITting 等),但我目前找不到它。 如果我再次遇到它,我会编辑这篇文章。
You can ngen your assembly using a custom installer action. The following link explains this in further detail:
http://www.dotnetperls.com/ngen
I can also remember a good discussion of Paint.NET's installer (which includes .NET Framework bootstrapping, pre-JITting etc.), but I cannot find it at the moment. I'll edit this post if I come across it again.
首先,“是”,您可以保证,如果他们安装了 .Net 框架,那么他们就有 Ngen。 您唯一需要知道的是他们安装了哪个版本,因为 1.1 和 2.0 之间有所不同。 我过去所做的只是创建一个脚本,我的安装程序在最后调用该脚本,该脚本在所有程序集上运行 ngen。
First of all "Yes" you can guarantee that if they have the .Net framework installed that they have Ngen. The only thing you need to know is which version they have installed, buecause it's different between 1.1, and 2.0. What I've done in the past is simply created a script that my installer calls at the very end which runs ngen on all the assemblies.
要提高启动时的感知性能,请查看应用程序中的静态数据。 启动应用程序时,大量静态数据可能会导致大量开销。
此外,请考虑仅将主窗体放在 EXE 中,而将其他所有内容放在单独的 DLL 中。 这不仅可以提高性能,还有助于确保将视图与数据分开。
最后,如果您设置了 NGENing,请查看有关在 MSI 中运行自定义操作的帮助。 您应该能够设置自定义操作来执行您想要的操作。
To improve the perceived performance at startup, take a look at statics in your application. Lots of statics can cause a significant amount of overhead when starting an application.
Additionally, consider having just your main form in the EXE and everything else in a seperate DLL. This not only improves performance but helps in guarenteeing that your seperating the view from the data.
Finally, if your set on NGENing, take a look at the help on running custom actions in your MSI. You should be able to set up a custom action to do what you want.
正如“Micah”所说,是,您会发现 NGen 与 .Net Framework 一起安装。
查看 WiX 3.5 安装程序示例,了解如何在安装过程中 NGen 程序集。
NGen:创建安装程序项目
我希望这会对您有所帮助。
As 'Micah' says, Yes, You'll find NGen installed with .Net Framework.
Take a look at WiX 3.5 installer examples how to NGen your assemblies during installation.
NGen: Creating Setup Projects
I hope this will help you.
启动
ngen.exe
:Launch
ngen.exe
: