.net-core - 使用 Inno Setup 启动 .NET Core 安装程序失败,结果代码为 2
问题描述
我正在尝试使用 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 错误是什么?还是我可以通过任何方式提取有关错误信息的更多详细信息?我尝试了空参数并尝试在互联网上搜索 Code 2 错误信息,但仍然没有运气。我曾尝试使用 Shellexec 并且都返回相同的结果
直接使用 .net exe 安装在本地运行良好
任何帮助或信息将不胜感激=)
解决方案
您正在尝试dotnet-runtime-3.1.10-win-x64.exe
在实际将其“安装”到之前运行{tmp}
:
BeforeInstall: InstallFramework
您必须使用AfterInstall
参数:
AfterInstall: InstallFramework
推荐阅读
- python-3.x - 如何禁止关键字参数?
- reactjs - React - 样式化组件、道具和 TypeScript
- node.js - 如何在节点 oAuth2 服务器中设置过期时间
- ruby-on-rails - Rails 连接两个不同的表,导致数据级联到下一行
- jquery - 如何将每个div设置为特定坐标jquery
- python - 尽管在 chrome 中工作,Xpath 无法在 scrapy 中工作
- iis - 尝试访问 index.php 时,它会重定向到 index 并显示 404 页面
- observable - 如何在 promise 函数中返回 Observable
- javascript - 使用 javascript 更改输入类型 =“日期”最小属性值
- c++ - 用 ofstream 替换 ifstream 没有效果