How do I run nGen at the end of the installation (

2020-06-11 13:54发布

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!

6条回答
The star\"
2楼-- · 2020-06-11 14:11

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.

查看更多
混吃等死
3楼-- · 2020-06-11 14:15

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.

查看更多
Deceive 欺骗
4楼-- · 2020-06-11 14:18

This blog post should be of use.

Edit: Since you're not using Wix, then this may be of use as well.

查看更多
戒情不戒烟
5楼-- · 2020-06-11 14:20

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.

查看更多
疯言疯语
6楼-- · 2020-06-11 14:21

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.

查看更多
smile是对你的礼貌
7楼-- · 2020-06-11 14:21

Launch ngen.exe:

>ngen install c:\myfiles\MyAssembly.exe
查看更多
登录 后发表回答