我正在尝试使用Inno Setup构建安装程序。我需要为.NET Core框架设置必备安装。到目前为止,我已经能够检测到.NET Core的存在。但是我在执行安装时遇到困难。
这是我到目前为止的代码:
[Files]
Source: "\\shared\path\dotnet-runtime-3.1.10-win-x64.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall; BeforeInstall: InstallFramework; \
Check: FrameworkIsNotInstalled
[Code]
var
CancelWithoutPrompt: boolean;
InstallValue: Cardinal;
function InitializeSetup(): Boolean;
begin
CancelWithoutPrompt := false;
result := true;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
if CurPageID=wpInstalling then
Confirm := not CancelWithoutPrompt;
end;
function FrameworkIsNotInstalled: Boolean;
begin
Result := not RegQueryDWordValue(HKEY_LOCAL_MACHINE,
'SOFTWARE\WOW6432Node\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.NETCore.App',
'3.1.10', InstallValue) or (InstallValue <> 1)
end;
procedure InstallFramework;
var
StatusText: string;
ResultCode: Integer;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing .net core framework...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\dotnet-runtime-3.1.10-win-x64.exe'), '/q /norestart', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
// you can interact with the user that the installation failed
MsgBox('.NET Core installation failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
CancelWithoutPrompt := true;
WizardForm.Close;
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;
我从安装中得到结果代码2的响应,任何人都可以启发我代码2错误是什么?还是以任何方式我可以提取有关错误信息的更多详细信息?我尝试使用空参数,并尝试在Internet上搜索Code 2错误信息,但还是没有运气。我曾经尝试过Shellexec并返回相同的结果
直接使用.net exe进行的安装在本地运行正常
任何帮助或信息将不胜感激=)
你尝试先运行,dotnet-runtime-3.1.10-win-x64.exe
然后再实际将其“安装”到{tmp}
:
BeforeInstall: InstallFramework
你必须使用AfterInstall
参数:
AfterInstall: InstallFramework
有效!谢谢!