From d62226ffa03cdf3e751f166792f8f59359ab8f9e Mon Sep 17 00:00:00 2001 From: lincube Date: Sun, 12 Apr 2026 17:28:33 +0800 Subject: [PATCH] =?UTF-8?q?fix.=20=E8=AF=95=E9=AA=8C=E6=80=A7=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=BD=BB=E9=87=8F=E7=89=88=E7=9A=84?= =?UTF-8?q?Dotnet=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 45 +++++++++----- LanMountainDesktop/LanMountainDesktop.csproj | 2 +- .../installer/LanMountainDesktop.iss | 62 +++++++++++++++++-- 3 files changed, 88 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf45623..3cd9255 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -109,21 +109,36 @@ jobs: $selfContained = "${{ matrix.self_contained }}" -eq "true" $publishDir = if ($selfContained) { "publish/windows-${{ matrix.arch }}" } else { "publish/windows-${{ matrix.arch }}-lite" } - dotnet publish LanMountainDesktop/LanMountainDesktop.csproj ` - -c Release ` - -o ./$publishDir ` - --self-contained:$selfContained ` - -r win-${{ matrix.arch }} ` - -p:PublishSingleFile=false ` - -p:SelfContained=$selfContained ` - -p:DebugType=none ` - -p:DebugSymbols=false ` - -p:PublishTrimmed=false ` - -p:PublishReadyToRun=false ` - -p:Version=${{ needs.prepare.outputs.version }} ` - -p:AssemblyVersion=${{ needs.prepare.outputs.assembly_version }} ` - -p:FileVersion=${{ needs.prepare.outputs.assembly_version }} ` - -p:InformationalVersion=${{ needs.prepare.outputs.informational_version }} + if ($selfContained) { + dotnet publish LanMountainDesktop/LanMountainDesktop.csproj ` + -c Release ` + -o ./$publishDir ` + --self-contained ` + -r win-${{ matrix.arch }} ` + -p:PublishSingleFile=false ` + -p:DebugType=none ` + -p:DebugSymbols=false ` + -p:PublishTrimmed=false ` + -p:PublishReadyToRun=false ` + -p:Version=${{ needs.prepare.outputs.version }} ` + -p:AssemblyVersion=${{ needs.prepare.outputs.assembly_version }} ` + -p:FileVersion=${{ needs.prepare.outputs.assembly_version }} ` + -p:InformationalVersion=${{ needs.prepare.outputs.informational_version }} + } else { + dotnet publish LanMountainDesktop/LanMountainDesktop.csproj ` + -c Release ` + -o ./$publishDir ` + --self-contained:false ` + -p:PublishSingleFile=false ` + -p:DebugType=none ` + -p:DebugSymbols=false ` + -p:PublishTrimmed=false ` + -p:PublishReadyToRun=false ` + -p:Version=${{ needs.prepare.outputs.version }} ` + -p:AssemblyVersion=${{ needs.prepare.outputs.assembly_version }} ` + -p:FileVersion=${{ needs.prepare.outputs.assembly_version }} ` + -p:InformationalVersion=${{ needs.prepare.outputs.informational_version }} + } Write-Host "Published to: $publishDir" Write-Host "Self-contained: $selfContained" diff --git a/LanMountainDesktop/LanMountainDesktop.csproj b/LanMountainDesktop/LanMountainDesktop.csproj index 67a3347..0a48cb6 100644 --- a/LanMountainDesktop/LanMountainDesktop.csproj +++ b/LanMountainDesktop/LanMountainDesktop.csproj @@ -2,12 +2,12 @@ WinExe net10.0 + LatestMajor enable 1.0.0 app.manifest Assets\logo_nightly.ico true - true diff --git a/LanMountainDesktop/installer/LanMountainDesktop.iss b/LanMountainDesktop/installer/LanMountainDesktop.iss index d648e6f..0229b14 100644 --- a/LanMountainDesktop/installer/LanMountainDesktop.iss +++ b/LanMountainDesktop/installer/LanMountainDesktop.iss @@ -454,21 +454,73 @@ begin RegQueryStringValue(HKCU32, WebView2RuntimeKeyPath, 'pv', VersionValue); end; +// Checks whether a .NET 10.x shared framework is installed under the given +// base path by enumerating version sub-directories and looking for one that +// starts with '10.'. +function IsDotNet10RuntimePresent(const BasePath: String): Boolean; +var + FindRec: TFindRec; +begin + Result := False; + if not DirExists(BasePath) then + begin + exit; + end; + + if FindFirst(BasePath + '\*', FindRec) then + begin + try + repeat + if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and + (Length(FindRec.Name) >= 3) and + (Copy(FindRec.Name, 1, 3) = '10.') then + begin + Result := True; + exit; + end; + until not FindNext(FindRec); + finally + FindClose(FindRec); + end; + end; +end; + +// Returns True when the .NET 10 Desktop Runtime (or the .NET 10 Core Runtime +// which is sufficient for Avalonia apps) is found on the system. +// We check both Microsoft.WindowsDesktop.App and Microsoft.NETCore.App because +// the runtimeconfig.json may reference either framework depending on the +// publish mode and the app only needs the one it actually references. function IsDotNetDesktopRuntimeInstalled(): Boolean; var - RuntimePath: String; + BasePath: String; begin Result := False; - RuntimePath := ExpandConstant('{commonpf64}\dotnet\shared\Microsoft.WindowsDesktop.App'); - if DirExists(RuntimePath) then + // Check 64-bit Program Files + BasePath := ExpandConstant('{commonpf64}\dotnet\shared\Microsoft.WindowsDesktop.App'); + if IsDotNet10RuntimePresent(BasePath) then begin Result := True; exit; end; - RuntimePath := ExpandConstant('{commonpf}\dotnet\shared\Microsoft.WindowsDesktop.App'); - if DirExists(RuntimePath) then + BasePath := ExpandConstant('{commonpf64}\dotnet\shared\Microsoft.NETCore.App'); + if IsDotNet10RuntimePresent(BasePath) then + begin + Result := True; + exit; + end; + + // Check 32-bit Program Files + BasePath := ExpandConstant('{commonpf}\dotnet\shared\Microsoft.WindowsDesktop.App'); + if IsDotNet10RuntimePresent(BasePath) then + begin + Result := True; + exit; + end; + + BasePath := ExpandConstant('{commonpf}\dotnet\shared\Microsoft.NETCore.App'); + if IsDotNet10RuntimePresent(BasePath) then begin Result := True; exit;