NGEN as postaction of an MSIX installation

Brass Contributor

Hi,

 

How can I run the Native Image Generator right after an MSIX package is installed successfully ?

1 Reply

@Sigmarsson  Great question!

 

So first of all, we are talking about .Net Framework based components here, and not .Net Core.  Traditionally, these exe/dll components exist in the installer package in MSIL form and are compiled using ngen as part of the installation. 

 

And yes, MSIX does not have a means to compile them on the target machine.  Ngen compilation requires administrator privilege's.  Even scripting using the PSF and a run-once script to compile as part of the deployment is problematic as elevation would be required at a time that the end-user might not have the ability to use.

 

Now originally, with .NET it was necessary to perform the compilation at the target machine because compilation was so different on different processors.  Over the years Microsoft has simplified this, and my experience has been that it is OK to precompile and deliver the ni and ni-aux files with the package. My understanding is that compilation is now specific to the processor architecture, by which Intel-AMD-x86-x64 all fit in one architecture, and things like ARM are a different architecture for this purpose.

 

For years we have recaptured the compiled .NET files inside of App-V packages and deployed them successfully, as App-V only supports that one architecture. So as long as you are careful about targeting, this might work for you.