How do I run nGen at the end of the installation (MSI)?
Asked Answered
S

5

11

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!

Survance answered 6/2, 2009 at 21:45 Comment(0)
E
8

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.

Eddins answered 11/5, 2009 at 16:49 Comment(3)
Thanks for the info, @Wouter. I've updated the dotnetperls link (they must have moved to MVC routing and not redirected old URLs). The bobpowell.net link still seems to be fine - could you retry?Eddins
Second link currently redirects to malware site.Molality
Hi @JimFoye Thanks so much for the heads-up. I've removed the link and hope it didn't cause any issues your end.Eddins
C
1

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.

Customer answered 6/2, 2009 at 21:57 Comment(0)
S
0

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.

Sisley answered 7/2, 2009 at 1:34 Comment(0)
T
0

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.

Thionic answered 17/3, 2011 at 9:37 Comment(0)
G
0

Launch ngen.exe:

>ngen install c:\myfiles\MyAssembly.exe
Gosser answered 7/11, 2013 at 2:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.