1

I am able to run the following in the cmd console and it works. I can see the difference when the app is loading and when executing task within.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe install "C:\Program Files (x86)\App Directroy\App.exe"

I am trying to have Inno perform the same when installing the app but, before the user has an opportunity to launch the app for the first time.

This is what I have tried so far with Inno:

[Run]
Filename: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe; Parameters: "install ""{app}\{#MyAppExeName}""";
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent"

What happens is that, when Inno finishes installing it starts the app and doesn't execute the ngen.

I am trying to find how to run the above code in the Inno script.

Am I placing the code in the correct section of the Inno script?

Any assistance is appreciated.

Regards,

Jo Srm
  • 21
  • 3
  • The code seems correct (except for hard-coded `C:\Windows\...` path). If it does not work for you, include installer log file (`/log=...`). – Martin Prikryl Jun 07 '22 at 17:36

1 Answers1

0

I read what Martin Prikryl said about the hard-coded c:\windows... and looked into it and I found this article from Fabrizio Stellato and I was able to get it to work.

I changed this part:

[Run]
Filename: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe; Parameters: "install ""{app}\{#MyAppExeName}""";

to

[Run]
Filename: "{win}\Microsoft.NET\Framework64\v4.0.30319\ngen.exe"; Parameters: "install ""{app}\{#MyAppExeName}"" /nologo"; WorkingDir: "{app}"; Flags: runhidden; StatusMsg: "Optimizing..."; Check: IsWin64

I added the {win} to replace the hard coded c:\windows

I hid the cmd console with Flags: runhidden;

Show the status to the user with StatusMsg: "Optimizing...";

Fabrizio Stellato has a complete solution:

Part 1 InnoSetup, optimize your application with ngen

Part 2 InnoSetup, Optimize your .NET Application with ngen - Part II

Regards,

Jo Srm
  • 21
  • 3
  • While using hard-coded path is wrong, as the path can be actually different, if it is not (what it most likely is not), replacing `c:\windows` with `{win}` would not have fixed it. Neither could adding `Flags: runhidden` nor `StatusMsg: "Optimizing..."`. It is more likely that adding of the `WorkingDir: "{app}"` was the fix. – Martin Prikryl Jun 08 '22 at 05:17