0

I'm make an installation wizard for my maui app with inno setup and am very close to complete it except for this problem after the app is installed and lunched the window is empty the image of the installed app after being launched my thou my published version works fine this is my file structure

win-x64/

├── appicon.ico

├── myapp.iss

├── Dependencies/

│   ├── WindowsAppRuntimeInstall-x64.exe

│   └── MicrosoftEdgeWebView2RuntimeInstallerX64.exe

│   └── VC_redist.x64.exe

└── publish/ win-x64 folder is where is my release build exist and it is a self-contant build

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
</PropertyGroup> 

publish is where is the published version of my app exist using this code dotnet publish -c Release -f net8.0-windows10.0.19041.0 --sc -p:RuntimeIdentifier=win-x64 -p:WindowsPackageType=None and yes this project is not build as an msix package it is an unpackage app myapp.iss file is where my inno code exists


#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 or version string is empty. Proceeding with installation.');
  Result := True; 
end;


function WindowsAppRuntimeNeedsInstall: Boolean;
begin
  Result := True;
end;

function InitializeSetup(): Boolean;
begin
  Log('Setup initialization started. AppName: {#MyAppName}, AppVersion: {#MyAppVersion}');
  Result := True;
end;

procedure DeinitializeSetup();
begin
    Log('Setup finished.');
end;

function InitializeUninstall(): Boolean;
begin
  Log('Uninstallation initialization started.');
  Result := True;
end;

procedure DeinitializeUninstall();
begin
  Log('Uninstallation finished.');
end;


so how to fix this problem

0

1 Answer 1

-3

thanks to Martin Prikryl post i found a two solution that works for me
first is to add the following to my code

[Icons]
Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; AfterInstall: SetElevationBit('{userdesktop}\{#MyAppName}.lnk')
[Code]

procedure SetElevationBit(Filename: string);
var
  Buffer: string;
  Stream: TStream;
begin
  Filename := ExpandConstant(Filename);
  Log('Setting elevation bit for ' + Filename);

  Stream := TFileStream.Create(FileName, fmOpenReadWrite);
  try
    Stream.Seek(21, soFromBeginning);
    SetLength(Buffer, 1);
    Stream.ReadBuffer(Buffer, 1);
    Buffer[1] := Chr(Ord(Buffer[1]) or $20);
    Stream.Seek(-1, soFromCurrent);
    Stream.WriteBuffer(Buffer, 1);
  finally
    Stream.Free;
  end;
end;

second and this is a bad solution and it's not a good practice at all is to add the following code which is basically make the installer grant a user(s) write permissions

[Dirs]
Name: {app}; Permissions: users-full

looks like my app need write Permissions to get installed
more details about this in Martin Prikryl's post

Sign up to request clarification or add additional context in comments.

3 Comments

And as noted there, this is a bad solution.
sorry, I just used the first one the worked without thinking about it, I was in a rush hope this answer is better and hope this post help any one who have problem with inno setup for blazor
That solution is labeled in my answer as "Even more gross workaround".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.