From 59b1061ec5b4c654a977becf6bfafeca27c9c51d Mon Sep 17 00:00:00 2001 From: Christ Date: Thu, 13 Aug 2026 15:08:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Windows=20=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=99=A8=E6=9E=84=E5=BB=BA=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/desktop-cd.yml | 39 ++++++++++++++++++++++++++++---- packaging/windows/installer.iss | 14 ++++++++---- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/.github/workflows/desktop-cd.yml b/.github/workflows/desktop-cd.yml index a9564eb..fd7dfe0 100644 --- a/.github/workflows/desktop-cd.yml +++ b/.github/workflows/desktop-cd.yml @@ -387,7 +387,29 @@ jobs: env: APP_VERSION: ${{ env.APP_VERSION }} run: | - & 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' /Qp /O"dist\windows" packaging\windows\installer.iss + $requiredSources = @( + 'dist/windows/xianyu-server.exe', + 'dist/windows/xianyu-tray.exe', + 'dist/windows/playwright-runtime/amd64', + 'icon/windows/icon.ico', + 'packaging/windows/service-control.ps1' + ) + foreach ($source in $requiredSources) { + if (-not (Test-Path -LiteralPath $source)) { + throw "Windows 安装器源文件或目录不存在: $source" + } + } + if ($null -eq (Get-ChildItem -LiteralPath 'dist/windows/playwright-runtime/amd64' -Recurse -File | Select-Object -First 1)) { + throw 'Windows 安装器 Playwright runtime 为空' + } + + $compiler = 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' + $scriptPath = (Resolve-Path 'packaging/windows/installer.iss').Path + $outputDir = (Resolve-Path 'dist/windows').Path + & $compiler /Qp "/O$outputDir" $scriptPath + if ($LASTEXITCODE -ne 0) { + throw "Inno Setup 编译失败,错误码: $LASTEXITCODE" + } $installer = Get-ChildItem -Path dist/windows -Filter 'Ydisks-Xianyu-Helper-Setup.exe' -Recurse | Select-Object -First 1 if ($null -eq $installer) { throw 'Inno Setup 未生成安装器' } $target = Join-Path (Resolve-Path dist/windows) 'Ydisks-Xianyu-Helper-Setup.exe' @@ -431,9 +453,18 @@ jobs: $expectedServer = Join-Path $installDir 'xianyu-server.exe' $expectedRuntime = Join-Path $installDir 'playwright-runtime' $serviceConfig = Get-CimInstance -ClassName Win32_Service -Filter "Name='$serviceName'" -ErrorAction Stop - if ($null -eq $serviceConfig -or - -not $serviceConfig.PathName.Contains(('"{0}"' -f $expectedServer)) -or - -not $serviceConfig.PathName.Contains(('-playwright-runtime-root "{0}"' -f $expectedRuntime))) { + $actualServiceCommand = if ($null -eq $serviceConfig) { '' } else { $serviceConfig.PathName.Replace('"', '') } + $requiredServiceArguments = @( + $expectedServer, + '-service', + "-playwright-runtime-root $expectedRuntime" + ) + $invalidServiceArgument = $requiredServiceArguments | + Where-Object { + $actualServiceCommand.IndexOf($_, [StringComparison]::OrdinalIgnoreCase) -lt 0 + } | + Select-Object -First 1 + if ($null -ne $invalidServiceArgument) { throw "安装器注册的服务命令行不正确: $($serviceConfig.PathName)" } diff --git a/packaging/windows/installer.iss b/packaging/windows/installer.iss index 589b9d6..71592f9 100644 --- a/packaging/windows/installer.iss +++ b/packaging/windows/installer.iss @@ -3,6 +3,10 @@ #define AppPublisher "Christ9038" #define AppExeName "xianyu-server.exe" #define AppDataDir "{commonappdata}\YdisksXianyuHelper" +#define RepoRoot AddBackslash(SourcePath) + "..\.." +#define WindowsDistDir AddBackslash(RepoRoot) + "dist\windows" +#define WindowsRuntimeDir AddBackslash(WindowsDistDir) + "playwright-runtime\amd64" +#define WindowsIconDir AddBackslash(RepoRoot) + "icon\windows" [Setup] AppId={{A6E8B04B-3C8A-4E20-AE62-6B1C3F6B31AE} @@ -16,15 +20,15 @@ PrivilegesRequired=admin ArchitecturesInstallIn64BitMode=x64compatible DisableProgramGroupPage=yes UninstallDisplayIcon={app}\icon.ico -SetupIconFile=..\..\icon\windows\icon.ico +SetupIconFile={#WindowsIconDir}\icon.ico Compression=lzma2 SolidCompression=yes [Files] -Source: "..\..\dist\windows\xianyu-server.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\..\dist\windows\xianyu-tray.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\..\icon\windows\icon.ico"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\..\dist\windows\playwright-runtime\*"; DestDir: "{app}\playwright-runtime"; Flags: recursesubdirs createallsubdirs ignoreversion +Source: "{#WindowsDistDir}\xianyu-server.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#WindowsDistDir}\xianyu-tray.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#WindowsIconDir}\icon.ico"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#WindowsRuntimeDir}\*"; DestDir: "{app}\playwright-runtime"; Flags: recursesubdirs createallsubdirs ignoreversion Source: "service-control.ps1"; Flags: dontcopy Source: "service-control.ps1"; DestDir: "{app}"; Flags: ignoreversion