NGEN as postaction of an MSIX installation

%3CLINGO-SUB%20id%3D%22lingo-sub-1522044%22%20slang%3D%22en-US%22%3ENGEN%20as%20postaction%20of%20an%20MSIX%20installation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1522044%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22%22%3EHow%20can%20I%20run%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ENative%20Image%20Generator%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Eright%20after%20an%20MSIX%20package%20is%20installed%20successfully%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1529057%22%20slang%3D%22en-US%22%3ERe%3A%20NGEN%20as%20postaction%20of%20an%20MSIX%20installation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1529057%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F682219%22%20target%3D%22_blank%22%3E%40Sigmarsson%3C%2FA%3E%26nbsp%3B%20Great%20question!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20first%20of%20all%2C%20we%20are%20talking%20about%20.Net%20Framework%20based%20components%20here%2C%20and%20not%20.Net%20Core.%26nbsp%3B%20Traditionally%2C%20these%20exe%2Fdll%20components%20exist%20in%20the%20installer%20package%20in%20MSIL%20form%20and%20are%20compiled%20using%20ngen%20as%20part%20of%20the%20installation.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20yes%2C%20MSIX%20does%20not%20have%20a%20means%20to%20compile%20them%20on%20the%20target%20machine.%26nbsp%3B%20Ngen%20compilation%20requires%20administrator%20privilege's.%26nbsp%3B%20Even%20scripting%20using%20the%20PSF%20and%20a%20run-once%20script%20to%20compile%20as%20part%20of%20the%20deployment%20is%20problematic%20as%20elevation%20would%20be%20required%20at%20a%20time%20that%20the%20end-user%20might%20not%20have%20the%20ability%20to%20use.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20originally%2C%20with%20.NET%20it%20was%20necessary%20to%20perform%20the%20compilation%20at%20the%20target%20machine%20because%20compilation%20was%20so%20different%20on%20different%20processors.%26nbsp%3B%20Over%20the%20years%20Microsoft%20has%20simplified%20this%2C%20and%20my%20experience%20has%20been%20that%20it%20is%20OK%20to%20precompile%20and%20deliver%20the%20ni%20and%20ni-aux%20files%20with%20the%20package.%20My%20understanding%20is%20that%20compilation%20is%20now%20specific%20to%20the%20processor%20architecture%2C%20by%20which%20Intel-AMD-x86-x64%20all%20fit%20in%20one%20architecture%2C%20and%20things%20like%20ARM%20are%20a%20different%20architecture%20for%20this%20purpose.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20years%20we%20have%20recaptured%20the%20compiled%20.NET%20files%20inside%20of%20App-V%20packages%20and%20deployed%20them%20successfully%2C%20as%20App-V%20only%20supports%20that%20one%20architecture.%20So%20as%20long%20as%20you%20are%20careful%20about%20targeting%2C%20this%20might%20work%20for%20you.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi,

 

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

1 Reply
Highlighted

@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.