You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Inno Setup制作.NET MAUI Blazor Hybrid应用安装向导后,启动应用出现空白窗口问题求助

Inno Setup制作.NET MAUI Blazor Hybrid应用安装向导后,启动应用出现空白窗口问题求助

各位大佬好!我正在给我的.NET MAUI Blazor Hybrid无包应用做Inno Setup安装程序,大部分流程都跑通了,但遇到了一个头疼的问题:用安装包装好应用后启动,窗口是空白的,可是直接运行我本地publish目录里的发布版exe却完全正常,功能一点问题都没有,实在搞不懂哪里出岔子了,来求大家帮忙看看!

先给大家说下我的项目情况:

  • 是.NET 8的MAUI应用,针对Windows平台,没有打包成MSIX,是自包含的无包应用
  • 发布命令用的是这个:
    dotnet publish -c Release -f net8.0-windows10.0.19041.0 --sc -p:RuntimeIdentifier=win-x64 -p:WindowsPackageType=None
    
  • 项目里的Windows相关MSBuild配置:
    <PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
      <RuntimeIdentifier>win-x64</RuntimeIdentifier>
      <SelfContained>true</SelfContained>
    </PropertyGroup>
    

我的文件目录结构是这样的(所有文件都放在win-x64目录下):

win-x64/
├── appicon.ico
├── myapp.iss       # Inno Setup的脚本文件
├── Dependencies/   # 存放需要预装的依赖安装包
│   ├── WindowsAppRuntimeInstall-x64.exe
│   ├── MicrosoftEdgeWebView2RuntimeInstallerX64.exe
│   └── VC_redist.x64.exe
└── publish/        # 用上面的dotnet publish生成的发布文件,直接跑这里的exe完全正常

下面是我的Inno Setup脚本内容:

#define MyAppName "[myappname]"
#define MyAppVersion "1.0.0"
#define MyAppPublisher "[myCompany]"
#define MyAppURL "https://www.mycompanywebiste.com"
#define MyAppExeName "[myappname].exe"
#define MyAppIconFullName "appicon.ico"
#define DependenciesFolderName "Dependencies"
#define PublishFolderName "publish"

[Setup]
AppId={{AUTO_GUID}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename=[myappname]_Setup_{#MyAppVersion}_x64
Compression=lzma
SolidCompression=yes
WizardStyle=modern
PrivilegesRequired=admin
ArchitecturesInstallIn64BitMode=x64
SetupIconFile={#MyAppIconFullName}
UninstallDisplayIcon={app}\{#MyAppIconFullName}
DisableDirPage=no

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "{#PublishFolderName}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#MyAppIconFullName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#DependenciesFolderName}\VC_redist.x64.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "{#DependenciesFolderName}\MicrosoftEdgeWebView2RuntimeInstallerX64.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "{#DependenciesFolderName}\WindowsAppRuntimeInstall-x64.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\{#MyAppIconFullName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: "{app}\{#MyAppIconFullName}"

[Run]
Filename: "{tmp}\VC_redist.x64.exe"; Parameters: "/install /passive /norestart"; StatusMsg: "Installing Microsoft Visual C++ Redistributable (x64)..."; Check: VCRedistNeedsInstall; Flags: skipifdoesntexist
Filename: "{tmp}\MicrosoftEdgeWebView2RuntimeInstallerX64.exe"; Parameters: "/silent /install"; StatusMsg: "Installing Microsoft Edge WebView2 Runtime..."; Check: WebView2RuntimeNeedsInstall; Flags: skipifdoesntexist
Filename: "{tmp}\WindowsAppRuntimeInstall-x64.exe"; Parameters: "-q --force"; StatusMsg: "Installing Windows App Runtime..."; Check: WindowsAppRuntimeNeedsInstall; Flags: skipifdoesntexist
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#MyAppName}}"; Flags: nowait postinstall skipifsilent unchecked

[Code]
function VCRedistNeedsInstall: Boolean;
begin
  Result := True;
end;

function WebView2RuntimeNeedsInstall: Boolean;
var
  Version: string;
begin
  if RegQueryStringValue(HKLM64, 'SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}', 'pv', Version) then
  begin
    if Version <> '' then
    begin
      Log(Format('WebView2 Runtime found (HKLM64), version: %s. Skipping installation.', [Version]));
      Result := False;
      Exit;
    end;
  end;
  if IsWin64 then
  begin
    if RegQueryStringValue(HKLM32, 'SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}', 'pv', Version) then
    begin
      if Version <> '' then
      begin
        Log(Format('WebView2 Runtime found (HKLM32 on Win64), version: %s. Skipping installation.', [Version]));
        Result := False;
        Exit;
      end;
    end;
  end;
  Log('WebView2 Runtime not found. Proceeding with installation.');
  Result := True;
end;

function WindowsAppRuntimeNeedsInstall: Boolean;
begin
  // 暂时直接返回True,确保依赖会被安装
  Result := True;
end;

我已经确认了安装过程中依赖项都正常安装了,而且安装目录里的文件和publish目录里的看起来是一样的,但就是启动后窗口空白。有没有大佬遇到过类似的问题?或者能帮我看看Inno脚本里有没有什么配置错了的地方?

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.08 11:38:02