I'm trying to call ngen with a CMD-script to create a native image of the application that is installed with InnoSetup. For that I run said script by calling ShellExec in the curStepChanged function when Curstep is ssPostInstall. The script itself looks up the location of ngen and calls it with the path of the application as parameter. The problem is that the script is stopped after aprox. 1 second without any errors. ShellExec returns true and the logfile created by the script is empty.
Here the Details: InnoSetup:
procedure CurStepChanged(CurStep: TSetupStep);
var
Param : String;
ResultCode : Integer;
begin
if CurStep=ssPostInstall then begin
try
ProgressPage.SetProgress(0,2);
ProgressPage.SetText('Tell Application about the Database','');
ProgressPage.Show;
Exec(ExpandConstant('{tmp}') + '\XMLAndIniReplacer.exe',ExpandConstant('{app}')+'\Application.exe.config'+ ' ' +DBPage.Values[0] + ' ' + DBPage.Values[1] + ' ' + DBPage.Values[2] + ' ' + DBPage.Values[3] + ' ' + ExpandConstant('{app}')+'\Application.ini' + ' ' + ExpandConstant('{language}'),'', SW_HIDE, ewWaitUntilTerminated, ResultCode)
ProgressPage.SetProgress(1,2);
ProgressPage.SetText('Make Application faster ','This operation could take a few minutes');
Param := '"' + ExpandConstant('{app}') + '"';
if not ShellExec('', ExpandConstant('{tmp}') + '\ngen-run.cmd', Param,'', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin
MsgBox(SysErrorMessage(ResultCode), mbError, MB_OK);
end;
ProgressPage.SetProgress(2,2);
finally
ProgressPage.Hide;
end;
end;
end;
CMD-File:
for /f "tokens=3* delims= " %%a in ('reg.exe query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework /v InstallRoot') do set "UTILPATH=%%a\v4.0.30319\ngen.exe"
echo %1
echo %2
echo %UTILPATH%
%UTILPATH% %2 %1\Application.exe > ngen.log
Everything works just fine, it's just that the script is called, open for about a second, and closes without telling me anything. Also there is no native image as a single second for a several megabyte heavy .exe would be ridiculously fast. Also the black magic that is casted in the CMD-File is the work of someone else. I can't tell what happens in there. I only know, that it calls ngen with the application as parameter. So far it worked perfectly fine. So whats wrong here?