diff --git a/Changelog/2026-10-04-installer-2026.10.4.4-dotnet10-prereq.md b/Changelog/2026-10-04-installer-2026.10.4.4-dotnet10-prereq.md new file mode 100644 index 0000000..98e2201 --- /dev/null +++ b/Changelog/2026-10-04-installer-2026.10.4.4-dotnet10-prereq.md @@ -0,0 +1,50 @@ +# RynthCore 2026.10.4.4: .NET 10 check with automatic download and install + +**Release date:** 2026-10-04 +**Installer:** `installer\Output\RynthCore-Setup-2026.10.4.4.exe` (also copied to `RynthCore-Setup.exe`) +**Previous release:** `2026.10.4.3` (archived to `installer\previous-release\RynthCore-Setup-2026.10.4.3.exe`) +**Branch:** `feat/full-installer` (local test build, not on `main`) + +## Installer: .NET 10 Desktop Runtime (x86) + +- **Detection:** setup looks for a 10.x `Microsoft.WindowsDesktop.App` under `Program Files (x86)\dotnet\shared\`, or its + registration in `HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\sharedfx\Microsoft.WindowsDesktop.App` (32-bit view). + x86 matches RynthCore's x86 launcher and tools. The Desktop Runtime also contains the base .NET runtime. +- **When it's missing,** the Tasks page shows a **Prerequisites** task, checked by default: *Download and install the + Microsoft .NET 10 Desktop Runtime (x86)*. When the runtime is already there, the task is not shown at all. +- **Install:** on leaving the Ready page, setup downloads the latest 10.x runtime from Microsoft + (`https://aka.ms/dotnet/10.0/windowsdesktop-runtime-win-x86.exe`, about 55 MB) with a progress page, then runs it + with `/install /quiet /norestart`. The runtime's own installer asks for administrator approval (UAC) when setup + isn't elevated. +- **Silent installs** run the same step just before the files are copied, without a progress page. Skip it with + `/MERGETASKS="!installdotnet"`. That's useful offline, or for the launcher's silent self-update when no one is + there to approve UAC. +- **Never blocking:** exit codes 0, 3010, 1641 and 1638 (a newer runtime is already installed) count as success. A + failed download, a cancelled UAC prompt (1602) or any other error is logged and shown in a message box with the + manual download link, and the RynthCore install carries on. + +Why it isn't required: the launcher, Loot Editor and Monster Editor are self-contained (they bundle .NET 10.0.5), and the +engine, loader and plugins are NativeAOT. The shared runtime is a safety net for framework-dependent add-ons and tools. +Earlier blocking .NET pages (0.4.x) had to be made advisory for exactly this reason. + +## Build script: .NET 10 SDK + +`Build-Installer.ps1` needs a .NET 10 SDK to publish, so before building (skipped with `-SkipBuild`) it: +1. uses the `dotnet` on PATH if it lists a 10.x SDK; +2. otherwise reuses an earlier per-user install in `%LOCALAPPDATA%\Microsoft\dotnet`; +3. otherwise downloads Microsoft's `dotnet-install.ps1`, **checks its Authenticode signature** (must be valid and signed + by Microsoft Corporation), and installs the latest 10.0 SDK per-user. No admin is needed. Then it uses that SDK for the + rest of the build (`DOTNET_ROOT` and `PATH` are set for this session only). + +Pass `-NoDotNetInstall` to fail with a download link instead of installing. + +**Tested:** in an isolated session with no `dotnet` on PATH, the script verified the signature, installed SDK 10.0.401 to +a scratch folder and found it again on a second run without re-downloading. + +NativeAOT publishing also needs the Visual Studio C++ build tools ("Desktop development with C++"). The script doesn't +install those. + +## Not tested end to end +The runtime download and install path in the installer was compiled but not run on the build machine. That machine already +has the x86 Desktop Runtime 10.0.7, so the task stays hidden there. Running it would have meant installing 10.0.12 +machine-wide. diff --git a/Changelog/2026-10-04-installer-2026.10.4.5-suite-dir-per-mode.md b/Changelog/2026-10-04-installer-2026.10.4.5-suite-dir-per-mode.md new file mode 100644 index 0000000..dd7dbb9 --- /dev/null +++ b/Changelog/2026-10-04-installer-2026.10.4.5-suite-dir-per-mode.md @@ -0,0 +1,31 @@ +# RynthCore 2026.10.4.5: installer only reuses a RynthSuite folder from the same install mode + +**Release date:** 2026-10-04 +**Installer:** `installer\Output\RynthCore-Setup-2026.10.4.5.exe` (also copied to `RynthCore-Setup.exe`) +**Previous release:** `2026.10.4.4` (archived to `installer\previous-release\RynthCore-Setup-2026.10.4.4.exe`). Don't +use 2026.10.4.4 for a per-user install on a machine that also has an all-users install (see below). +**Branch:** `feat/full-installer` (local test build, not on `main`) + +## Fix + +To pre-fill the **Select RynthSuite Location** page, the installer used to read `Software\Rynth\SuiteDir` from HKCU **and +then HKLM**. A per-user install on a machine that already had an all-users install therefore adopted the all-users +RynthSuite folder. The two installs then shared those files, and **uninstalling the per-user install deleted the +all-users install's RynthAi DLL and Monster Editor.** + +The lookup now reads only the hive of the current install mode (Inno's `HKA`: HKCU for per-user, HKLM for all-users), +matching how `GetPreviousData` and `UsePreviousAppDir` already behave. A per-user install with no per-user history +defaults to a `RynthSuite` folder next to its RynthCore folder again. + +The runtime resolver (`RynthInstallPaths`: HKCU, then HKLM) is unchanged. A per-user install's own values still +take precedence for that user. + +## Found by +A per-user test install of 2026.10.4.4 into a scratch folder on the build machine, which had an all-users 2026.10.4.3 +install in `C:\Games`. The test install wrote into `C:\Games\RynthSuite` and its uninstall removed +`RynthAi\RynthCore.Plugin.RynthAi.dll` and the Monster Editor. Both were restored right away from the same-source build +(RynthAi 0.5.3, 217 Monster Editor files). User data folders, the experimental plugins and `C:\Games\RynthCore` were not affected. + +## Also in this build +Everything from 2026.10.4.4: the .NET 10 Desktop Runtime check with automatic download and install in the installer, +and the .NET 10 SDK check with per-user auto-install in `Build-Installer.ps1`. diff --git a/installer/Build-Installer.ps1 b/installer/Build-Installer.ps1 index 91425bd..ba0d25c 100644 --- a/installer/Build-Installer.ps1 +++ b/installer/Build-Installer.ps1 @@ -5,6 +5,7 @@ (RynthCore-Setup-.exe) via Inno Setup. .DESCRIPTION + 0. Makes sure a .NET 10 SDK is available; installs one per-user when missing (see -NoDotNetInstall) 1. Publishes the Avalonia launcher (self-contained, x86) 2. Publishes RynthCore.Engine (NativeAOT, x86 -- ~2 min) 3. Publishes RynthCore.Loader (NativeAOT, x86) -- the DLL the launcher injects @@ -39,6 +40,11 @@ .PARAMETER SkipBuild Skip dotnet publish steps and just re-stage + re-run ISCC against existing publish output. + +.PARAMETER NoDotNetInstall + Fail instead of auto-installing when no .NET 10 SDK is found. By default a missing SDK is + installed per-user (no admin) to %LOCALAPPDATA%\Microsoft\dotnet via Microsoft's signed + dotnet-install.ps1, and used for this build. #> param( [string]$Configuration = "Release", @@ -49,7 +55,8 @@ param( # Version string injected into the installer (yyyy.m.d.n). When omitted, # the version defined in RynthCore.iss is used as-is. [string]$Version = "", - [switch]$SkipBuild + [switch]$SkipBuild, + [switch]$NoDotNetInstall ) $ErrorActionPreference = "Stop" @@ -75,6 +82,59 @@ if ($Version) { $VersionArgs = @() if ($Version) { $VersionArgs = @("-p:Version=$Version") } +# ── .NET 10 SDK check (auto-install when missing) ─────────────────────────── +# Every project targets net10.0, so publishing needs a .NET 10 SDK. Returns $true when the +# 'dotnet' on PATH lists a 10.x SDK. +function Test-DotNet10Sdk { + $cmd = Get-Command dotnet -ErrorAction SilentlyContinue + if (-not $cmd) { return $false } + $sdks = & $cmd.Source --list-sdks 2>$null + return [bool]($sdks | Where-Object { $_ -match '^10\.' }) +} + +# Makes a .NET 10 SDK available for this build: uses the one on PATH, else a previous per-user +# auto-install, else installs one per-user (no admin) with Microsoft's dotnet-install.ps1, whose +# Authenticode signature must verify as Microsoft before it is run. +function Initialize-DotNet10Sdk { + if (Test-DotNet10Sdk) { Write-Host ".NET 10 SDK: found ($((Get-Command dotnet).Source))"; return } + + $userDotNet = Join-Path $env:LOCALAPPDATA "Microsoft\dotnet" + if (Test-Path (Join-Path $userDotNet "dotnet.exe")) { + $env:DOTNET_ROOT = $userDotNet + $env:PATH = "$userDotNet;$env:PATH" + if (Test-DotNet10Sdk) { Write-Host ".NET 10 SDK: found per-user install ($userDotNet)"; return } + } + + if ($NoDotNetInstall) { + throw "No .NET 10 SDK found. Install it from https://dotnet.microsoft.com/download/dotnet/10.0 or re-run without -NoDotNetInstall." + } + + Write-Host "" + Write-Host ".NET 10 SDK not found -- installing it per-user to $userDotNet ..." -ForegroundColor Yellow + $installScript = Join-Path $env:TEMP "dotnet-install.ps1" + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 + Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile $installScript -UseBasicParsing + $sig = Get-AuthenticodeSignature $installScript + if ($sig.Status -ne 'Valid' -or $sig.SignerCertificate.Subject -notmatch 'O=Microsoft Corporation') { + Remove-Item $installScript -Force -ErrorAction SilentlyContinue + throw "dotnet-install.ps1 signature check failed ($($sig.Status)); not running it." + } + + # Separate process so the script runs under Bypass regardless of this session's execution policy. + & powershell -NoProfile -ExecutionPolicy Bypass -File $installScript -Channel 10.0 -InstallDir $userDotNet + $installExit = $LASTEXITCODE + Remove-Item $installScript -Force -ErrorAction SilentlyContinue + if ($installExit -ne 0) { throw "dotnet-install.ps1 failed (exit $installExit)" } + + $env:DOTNET_ROOT = $userDotNet + $env:PATH = "$userDotNet;$env:PATH" + if (-not (Test-DotNet10Sdk)) { throw ".NET 10 SDK install finished but 'dotnet --list-sdks' still shows no 10.x SDK." } + Write-Host ".NET 10 SDK: installed ($userDotNet)" -ForegroundColor Green +} + +# Only the publish steps need the SDK; -SkipBuild just re-stages and re-runs ISCC. +if (-not $SkipBuild) { Initialize-DotNet10Sdk } + $ScriptDir = $PSScriptRoot $RepoRoot = Split-Path $ScriptDir -Parent # e.g. C:\Projects\RynthCore $ProjectsRoot = Split-Path $RepoRoot -Parent # e.g. C:\Projects diff --git a/installer/RynthCore.iss b/installer/RynthCore.iss index 967a42c..5f4025a 100644 --- a/installer/RynthCore.iss +++ b/installer/RynthCore.iss @@ -10,6 +10,8 @@ ; Both are recorded under HKA\Software\Rynth (CoreDir / SuiteDir); the engine, launcher and plugins ; resolve every path from there (RynthInstallPaths.cs), so neither folder has to be under C:\Games. ; Silent installs: /DIR="" /SUITEDIR="". +; Prerequisite: when the .NET 10 Desktop Runtime (x86) is missing, the "installdotnet" task (on by default) +; downloads it from Microsoft and installs it before the files are copied. A failure is reported, never fatal. ; ; NOTE: No ISPP (#define / {#...}) macros are used in this file. ; Build-Installer.ps1 replaces the AppVersion placeholder via text substitution @@ -70,6 +72,9 @@ Name: "experimental\rynthvision"; Description: "RynthVision - unclimbable slope [Tasks] Name: desktopicon; Description: "Create a &desktop shortcut"; GroupDescription: "Additional icons:" +; Only offered when the runtime is missing. RynthCore and its tools are self-contained / NativeAOT and run +; without it; it is installed for framework-dependent add-ons and tools. Skip silently with /MERGETASKS="!installdotnet". +Name: installdotnet; Description: "Download and install the Microsoft .NET 10 Desktop Runtime (x86, about 55 MB; may ask for administrator approval)"; GroupDescription: "Prerequisites:"; Check: DotNet10DesktopMissing ; Files left by older layouts (the 0.4.x RynthBundle put a framework-dependent launcher, the engine ; and plugins straight into {app}). Mixing those with a newer launcher is what broke 2026-10-04's @@ -157,9 +162,16 @@ Filename: "{app}\RynthCore.exe"; WorkingDir: "{app}"; Flags: nowait runasorigina [Code] const DefaultSuiteDir = 'C:\Games\RynthSuite'; + { Microsoft's permalink to the latest .NET 10 Desktop Runtime (x86 to match RynthCore's x86 binaries). } + DotNetDesktopUrl = 'https://aka.ms/dotnet/10.0/windowsdesktop-runtime-win-x86.exe'; + DotNetDesktopFile = 'windowsdesktop-runtime-10-win-x86.exe'; + DotNetManualUrl = 'https://dotnet.microsoft.com/download/dotnet/10.0'; var SuiteDirPage: TInputDirWizardPage; + DotNetDownloadPage: TDownloadWizardPage; + { Set once the .NET step ran (interactive: on leaving the Ready page; silent: in PrepareToInstall). } + DotNetHandled: Boolean; { True once the user (or /SUITEDIR / a previous install) chose the Suite folder explicitly; until then it follows the RynthCore folder as a sibling "RynthSuite" folder. } SuiteDirPinned: Boolean; @@ -193,13 +205,14 @@ begin end; end; -{ Suite folder recorded by an earlier install (HKCU first, then HKLM), or ''. } +{ Suite folder recorded by an earlier install in the SAME install mode (HKA: HKCU per-user, HKLM all-users), + or ''. Never adopt the other mode's folder: two installs sharing a Suite folder would delete each other's + files on uninstall. } function RegisteredSuiteDir: string; begin Result := ''; - if not RegQueryStringValue(HKCU, 'Software\Rynth', 'SuiteDir', Result) then - if not RegQueryStringValue(HKLM, 'Software\Rynth', 'SuiteDir', Result) then - Result := ''; + if not RegQueryStringValue(HKA, 'Software\Rynth', 'SuiteDir', Result) then + Result := ''; end; { Default Suite folder for a given RynthCore folder: its sibling "RynthSuite". } @@ -274,6 +287,115 @@ begin Result := GetPendingPlugins('') <> ''; end; +{ ── .NET 10 Desktop Runtime (x86) ─────────────────────────────────────────── } + +{ True when Root (a ...\shared\Microsoft.WindowsDesktop.App folder) holds a 10.x version folder. } +function HasVersion10Folder(const Root: string): Boolean; +var + FindRec: TFindRec; +begin + Result := False; + if FindFirst(AddBackslash(Root) + '10.*', FindRec) then + try + repeat + if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then + begin + Result := True; + Exit; + end; + until not FindNext(FindRec); + finally + FindClose(FindRec); + end; +end; + +{ Detects the x86 Desktop Runtime 10.x the way the .NET host does: the shared framework folder under + Program Files (x86)\dotnet, or the installer's registration in the 32-bit registry view. } +function IsDotNet10DesktopX86Installed: Boolean; +var + Names: TArrayOfString; + I: Integer; +begin + Result := HasVersion10Folder(ExpandConstant('{commonpf32}\dotnet\shared\Microsoft.WindowsDesktop.App')); + if Result then Exit; + if RegGetValueNames(HKLM32, 'SOFTWARE\dotnet\Setup\InstalledVersions\x86\sharedfx\Microsoft.WindowsDesktop.App', Names) then + for I := 0 to GetArrayLength(Names) - 1 do + if Copy(Names[I], 1, 3) = '10.' then + begin + Result := True; + Exit; + end; +end; + +// Check function for the installdotnet task: offer it only when the runtime is missing. +function DotNet10DesktopMissing: Boolean; +begin + Result := not IsDotNet10DesktopX86Installed; +end; + +function OnDotNetDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean; +begin + Result := True; { never cancel from code; the download page has its own Abort button } +end; + +{ Downloads and runs the .NET 10 Desktop Runtime installer when the task is selected and the runtime is + still missing. Returns '' on success / nothing to do, else a reason. Never blocks the RynthCore install. } +function InstallDotNetRuntime(UsePage: Boolean): string; +var + SetupPath: string; + ResultCode: Integer; +begin + Result := ''; + DotNetHandled := True; + if not WizardIsTaskSelected('installdotnet') or IsDotNet10DesktopX86Installed then + Exit; + + Log('.NET 10 Desktop Runtime (x86) missing; downloading ' + DotNetDesktopUrl); + try + if UsePage then + begin + DotNetDownloadPage.Clear; + DotNetDownloadPage.Add(DotNetDesktopUrl, DotNetDesktopFile, ''); + DotNetDownloadPage.Show; + try + DotNetDownloadPage.Download; + finally + DotNetDownloadPage.Hide; + end; + end + else + DownloadTemporaryFile(DotNetDesktopUrl, DotNetDesktopFile, '', @OnDotNetDownloadProgress); + except + Result := 'the download failed (' + GetExceptionMessage + ')'; + Exit; + end; + + { The runtime's own bundle asks for elevation (UAC) itself when this setup is not elevated. } + SetupPath := ExpandConstant('{tmp}\' + DotNetDesktopFile); + Log('Running ' + SetupPath + ' /install /quiet /norestart'); + if not ShellExec('', SetupPath, '/install /quiet /norestart', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then + Result := 'its installer could not be started (' + SysErrorMessage(ResultCode) + ')' + { 0 = installed, 3010/1641 = installed (restart pending/started), 1638 = a newer version is already installed } + else if (ResultCode <> 0) and (ResultCode <> 3010) and (ResultCode <> 1641) and (ResultCode <> 1638) then + Result := 'its installer exited with code ' + IntToStr(ResultCode) + ' (1602 = cancelled)' + else + Log('.NET 10 Desktop Runtime installer finished, exit code ' + IntToStr(ResultCode)); +end; + +{ Runs the .NET step and reports (but never fails on) a problem. } +procedure HandleDotNetRuntime(UsePage: Boolean); +var + Problem: string; +begin + Problem := InstallDotNetRuntime(UsePage); + if Problem = '' then Exit; + Log('.NET 10 Desktop Runtime was not installed: ' + Problem); + if not WizardSilent then + MsgBox('The Microsoft .NET 10 Desktop Runtime could not be installed: ' + Problem + '.' + #13#10#13#10 + + 'RynthCore will still be installed and works without it (it is self-contained). ' + + 'You can install the runtime later from:' + #13#10 + DotNetManualUrl, mbInformation, MB_OK); +end; + procedure InitializeWizard; var Initial: string; @@ -295,6 +417,10 @@ begin SuiteDirPinned := Initial <> ''; if Initial = '' then Initial := DefaultSuiteDir; SuiteDirPage.Values[0] := Initial; + + { Progress page for the optional .NET 10 Desktop Runtime download (shown only when that task runs). } + DotNetDownloadPage := CreateDownloadPage('Downloading Prerequisites', + 'Downloading the Microsoft .NET 10 Desktop Runtime (x86)...', @OnDotNetDownloadProgress); end; procedure RegisterPreviousData(PreviousDataKey: Integer); @@ -330,6 +456,18 @@ begin end; SuiteDirPinned := True; end; + + { Leaving the Ready page: fetch/install the .NET runtime first (with a progress page) if that task is on. } + if CurPageID = wpReady then + HandleDotNetRuntime(True); +end; + +// Silent installs skip the wizard pages, so the .NET step runs here instead (no progress page). Never blocks. +function PrepareToInstall(var NeedsRestart: Boolean): String; +begin + if not DotNetHandled then + HandleDotNetRuntime(False); + Result := ''; end; function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, diff --git a/installer/previous-release/last-built-version.txt b/installer/previous-release/last-built-version.txt index 5007e22..1338193 100644 --- a/installer/previous-release/last-built-version.txt +++ b/installer/previous-release/last-built-version.txt @@ -1 +1 @@ -2026.10.4.3 \ No newline at end of file +2026.10.4.5 \ No newline at end of file