Skip to content

Commit 5360e47

Browse files
committed
fix(release): bundle VC runtime dependencies
1 parent f52b829 commit 5360e47

10 files changed

Lines changed: 363 additions & 14 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ jobs:
394394
mkdir publish\SetupEngine
395395
copy publish-setup\* publish\SetupEngine\ -Recurse
396396
397+
- name: Verify x64 Native Runtime Payload
398+
if: matrix.rid == 'win-x64'
399+
shell: pwsh
400+
run: .\scripts\Test-ReleaseNativeDependencies.ps1 -PayloadPath publish -RequireAppLocalVCRuntime
401+
397402
- name: Verify GitVersion assembly metadata
398403
shell: pwsh
399404
run: |
@@ -599,11 +604,34 @@ jobs:
599604
shell: pwsh
600605
run: .\scripts\Test-ReleaseExecutableSignatures.ps1 -PayloadPath artifacts/tray-win-arm64 -RequireSignedOpenClaw
601606

602-
# Create ZIP files for Updatum auto-update (needs "win-x64" in filename)
603-
- name: Create Release ZIPs
607+
- name: Verify x64 Release Native Dependencies
608+
shell: pwsh
609+
run: .\scripts\Test-ReleaseNativeDependencies.ps1 -PayloadPath artifacts/tray-win-x64 -RequireAppLocalVCRuntime
610+
611+
- name: Download Visual C++ Runtime Redistributables
612+
shell: pwsh
613+
run: |
614+
$redists = @(
615+
@{ Uri = "https://aka.ms/vc14/vc_redist.x64.exe"; Path = "vc_redist.x64.exe" },
616+
@{ Uri = "https://aka.ms/vc14/vc_redist.arm64.exe"; Path = "vc_redist.arm64.exe" }
617+
)
618+
619+
foreach ($redist in $redists) {
620+
Invoke-WebRequest -Uri $redist.Uri -OutFile $redist.Path
621+
$signature = Get-AuthenticodeSignature -LiteralPath $redist.Path
622+
if ($signature.Status -ne "Valid") {
623+
throw "$($redist.Path) Authenticode signature was $($signature.Status)."
624+
}
625+
$subject = if ($signature.SignerCertificate) { $signature.SignerCertificate.Subject } else { "" }
626+
if ($subject -notmatch "O=Microsoft Corporation") {
627+
throw "$($redist.Path) signer was not Microsoft Corporation: $subject"
628+
}
629+
}
630+
631+
# Create ZIP file for Updatum auto-update (needs "win-x64" in filename)
632+
- name: Create x64 Release ZIP
604633
run: |
605634
Compress-Archive -Path artifacts/tray-win-x64/* -DestinationPath OpenClawTray-${{ needs.test.outputs.semVer }}-win-x64.zip
606-
Compress-Archive -Path artifacts/tray-win-arm64/* -DestinationPath OpenClawTray-${{ needs.test.outputs.semVer }}-win-arm64.zip
607635
608636
# Inno Setup installer for x64
609637
- name: Install Inno Setup
@@ -614,16 +642,18 @@ jobs:
614642
# Prepare x64 files
615643
mkdir publish-x64
616644
copy artifacts/tray-win-x64/* publish-x64/ -Recurse
645+
.\scripts\Test-ReleaseNativeDependencies.ps1 -PayloadPath publish-x64 -RequireAppLocalVCRuntime -RequireInstallerVCRedist -InstallerVCRedistPath vc_redist.x64.exe
617646
# Build installer
618-
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DMyAppVersion=${{ needs.test.outputs.majorMinorPatch }} /DMyAppArch=x64 /Dpublish=publish-x64 installer.iss
647+
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DMyAppVersion=${{ needs.test.outputs.majorMinorPatch }} /DMyAppArch=x64 /Dpublish=publish-x64 /DvcRedist=vc_redist.x64.exe installer.iss
619648
620649
- name: Build arm64 Installer
621650
run: |
622651
# Prepare arm64 files
623652
mkdir publish-arm64
624653
copy artifacts/tray-win-arm64/* publish-arm64/ -Recurse
654+
.\scripts\Test-ReleaseNativeDependencies.ps1 -PayloadPath publish-arm64 -RequireInstallerVCRedist -InstallerVCRedistPath vc_redist.arm64.exe -SkipNativeLoadProbe
625655
# Build installer
626-
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DMyAppVersion=${{ needs.test.outputs.majorMinorPatch }} /DMyAppArch=arm64 /Dpublish=publish-arm64 installer.iss
656+
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DMyAppVersion=${{ needs.test.outputs.majorMinorPatch }} /DMyAppArch=arm64 /Dpublish=publish-arm64 /DvcRedist=vc_redist.arm64.exe installer.iss
627657
628658
- name: Sign Installers
629659
uses: azure/artifact-signing-action@v2
@@ -645,7 +675,6 @@ jobs:
645675
Output/OpenClawCompanion-Setup-x64.exe
646676
Output/OpenClawCompanion-Setup-arm64.exe
647677
OpenClawTray-${{ needs.test.outputs.semVer }}-win-x64.zip
648-
OpenClawTray-${{ needs.test.outputs.semVer }}-win-arm64.zip
649678
prerelease: ${{ contains(github.ref_name, '-') }}
650679
make_latest: ${{ contains(github.ref_name, '-') && 'false' || 'true' }}
651680
body: |
@@ -655,7 +684,6 @@ jobs:
655684
- **Installer (x64)**: `OpenClawCompanion-Setup-x64.exe` - Intel/AMD 64-bit
656685
- **Installer (ARM64)**: `OpenClawCompanion-Setup-arm64.exe` - Windows on ARM (Surface, etc.)
657686
- **Portable x64**: `OpenClawTray-${{ needs.test.outputs.semVer }}-win-x64.zip`
658-
- **Portable ARM64**: `OpenClawTray-${{ needs.test.outputs.semVer }}-win-arm64.zip`
659687
660688
### Features
661689
- 🦞 System tray integration with gateway status

‎docs/RELEASING.md‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ For the current alpha flow, ship only:
6969
- Inno setup installers:
7070
- `OpenClawCompanion-Setup-x64.exe`
7171
- `OpenClawCompanion-Setup-arm64.exe`
72-
- Portable ZIP payloads for Updatum:
72+
- Portable ZIP payload for Updatum:
7373
- `OpenClawTray-<version>-win-x64.zip`
74-
- `OpenClawTray-<version>-win-arm64.zip`
7574

7675
MSIX artifacts are intentionally paused for alpha while we focus on the Inno
7776
installer path and signed portable update payloads. Re-enable MSIX only when we
@@ -100,6 +99,16 @@ CI enforces this with `scripts\Test-ReleaseExecutableSignatures.ps1`. The
10099
verifier fails closed on unknown `.exe` files so future payload changes are
101100
reviewed deliberately.
102101

102+
CI also checks native runtime dependencies before release packaging. The x64
103+
portable payload must ship `vcruntime140.dll` next to every `libsodium.dll`
104+
copy. The release job must Authenticode-verify Microsoft's x64 and ARM64 Visual
105+
C++ Runtime redistributables before passing the architecture-matching
106+
redistributable to Inno. The installer runs the redistributable before launching
107+
the tray so clean or stale Windows hosts can repair the runtime before Ed25519
108+
device keys are generated or loaded, and it skips the post-install tray launch
109+
if the runtime installer fails. ARM64 portable ZIPs are paused until the release
110+
pipeline has a trusted app-local ARM64 VC runtime source.
111+
103112
The current Azure Artifact Signing resource is:
104113

105114
- Account: `openclaw`
@@ -150,10 +159,10 @@ The release job should:
150159
2. Authenticate to Azure with OIDC in the `release-signing` environment.
151160
3. Sign only the OpenClaw-owned EXEs in both payloads.
152161
4. Verify executable signing policy.
153-
5. Create portable ZIPs.
162+
5. Create the portable x64 ZIP.
154163
6. Build Inno installers.
155164
7. Sign installers.
156-
8. Create a GitHub prerelease with installer and ZIP assets only.
165+
8. Create a GitHub prerelease with installer and x64 ZIP assets only.
157166

158167
## Post-release verification
159168

‎installer.iss‎

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
6262
#error SetupEngine.UI payload missing. Publish OpenClaw.SetupEngine.UI into {#publish}\SetupEngine before compiling the installer.
6363
#endif
6464

65+
; vcRedist should point at the architecture-matching Visual C++ Runtime
66+
; redistributable in CI release builds.
67+
#ifndef vcRedist
68+
#define vcRedist ""
69+
#endif
70+
6571
[Tasks]
6672
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
6773
Name: "startupicon"; Description: "Start OpenClaw Companion when Windows starts"; GroupDescription: "Startup:"; Flags: unchecked
@@ -71,6 +77,9 @@ Name: "startupicon"; Description: "Start OpenClaw Companion when Windows starts"
7177
Source: "{#publish}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
7278
; WSL gateway uninstall helper copied to {tmp} by [Code] during uninstall.
7379
Source: "scripts\Uninstall-LocalGateway.ps1"; DestDir: "{app}"; Flags: ignoreversion
80+
#if vcRedist != ""
81+
Source: "{#vcRedist}"; DestDir: "{tmp}"; DestName: "vc_redist.exe"; Flags: deleteafterinstall; AfterInstall: InstallVCRuntime
82+
#endif
7483

7584
[Registry]
7685
Root: HKCU; Subkey: "Software\Classes\openclaw"; ValueType: string; ValueName: ""; ValueData: "URL:OpenClaw Protocol"; Flags: uninsdeletekey
@@ -89,14 +98,57 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: de
8998
Name: "{userstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: startupicon
9099

91100
[Run]
92-
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
101+
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent; Check: ShouldLaunchTray
93102

94103
[Code]
95104
var
105+
VCRuntimeInstallSucceeded: Boolean;
96106
LocalGatewayCleanupChoiceInitialized: Boolean;
97107
LocalGatewayCleanupRequested: Boolean;
98108
LocalGatewayCleanupSucceeded: Boolean;
99109
110+
#if vcRedist != ""
111+
procedure InstallVCRuntime;
112+
var
113+
ResultCode: Integer;
114+
Started: Boolean;
115+
begin
116+
VCRuntimeInstallSucceeded := False;
117+
Log('Running bundled Visual C++ Runtime redistributable.');
118+
Started :=
119+
Exec(
120+
ExpandConstant('{tmp}\vc_redist.exe'),
121+
'/install /quiet /norestart',
122+
'',
123+
SW_HIDE,
124+
ewWaitUntilTerminated,
125+
ResultCode);
126+
127+
if not Started then
128+
begin
129+
Log('Failed to start Visual C++ Runtime redistributable. System error: ' + IntToStr(ResultCode) + '.');
130+
Exit;
131+
end;
132+
133+
VCRuntimeInstallSucceeded := (ResultCode = 0) or (ResultCode = 3010) or (ResultCode = 1641);
134+
if VCRuntimeInstallSucceeded then
135+
Log('Visual C++ Runtime redistributable exited with success code ' + IntToStr(ResultCode) + '.')
136+
else
137+
Log('Visual C++ Runtime redistributable failed with exit code ' + IntToStr(ResultCode) + '.');
138+
end;
139+
#endif
140+
141+
function ShouldLaunchTray: Boolean;
142+
begin
143+
#if vcRedist != ""
144+
Result := VCRuntimeInstallSucceeded;
145+
if not Result then
146+
Log('Skipping post-install tray launch because Visual C++ Runtime installation did not succeed.');
147+
#else
148+
Result := True;
149+
#endif
150+
end;
151+
100152
procedure EnsureLocalGatewayCleanupChoice;
101153
begin
102154
if LocalGatewayCleanupChoiceInitialized then
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<#
2+
.SYNOPSIS
3+
Verifies native release payload dependencies needed on clean Windows hosts.
4+
5+
.DESCRIPTION
6+
The Windows node uses NSec.Cryptography, which loads libsodium.dll. The
7+
NuGet-provided Windows libsodium binary imports the Visual C++ runtime, so
8+
app-local/installer payloads must make that runtime available before the
9+
tray can generate or load device keys.
10+
#>
11+
[CmdletBinding()]
12+
param(
13+
[Parameter(Mandatory = $true)]
14+
[string]$PayloadPath,
15+
16+
[switch]$RequireAppLocalVCRuntime,
17+
18+
[switch]$RequireInstallerVCRedist,
19+
20+
[string]$InstallerVCRedistPath,
21+
22+
[switch]$SkipNativeLoadProbe
23+
)
24+
25+
Set-StrictMode -Version Latest
26+
$ErrorActionPreference = "Stop"
27+
28+
$payloadRoot = (Resolve-Path -LiteralPath $PayloadPath).Path
29+
$errors = New-Object System.Collections.Generic.List[string]
30+
$runningOnWindows = $env:OS -eq "Windows_NT"
31+
$shouldProbeNativeLoad = $runningOnWindows -and -not $SkipNativeLoadProbe
32+
33+
if ($shouldProbeNativeLoad -and
34+
-not ([System.Management.Automation.PSTypeName]"OpenClawNativeDependencyProbe").Type) {
35+
Add-Type @"
36+
using System;
37+
using System.Runtime.InteropServices;
38+
39+
public static class OpenClawNativeDependencyProbe {
40+
[DllImport("kernel32", SetLastError=true, CharSet=CharSet.Unicode)]
41+
public static extern IntPtr LoadLibrary(string lpFileName);
42+
43+
[DllImport("kernel32", SetLastError=true, CharSet=CharSet.Unicode)]
44+
public static extern bool SetDllDirectory(string lpPathName);
45+
}
46+
"@
47+
}
48+
49+
function Get-RelativePath {
50+
param(
51+
[Parameter(Mandatory = $true)][string]$Root,
52+
[Parameter(Mandatory = $true)][string]$Path
53+
)
54+
55+
[System.IO.Path]::GetRelativePath($Root, $Path).Replace('/', '\')
56+
}
57+
58+
function Add-MicrosoftSignatureErrors {
59+
param(
60+
[Parameter(Mandatory = $true)]
61+
[System.IO.FileInfo]$File
62+
)
63+
64+
if (-not $runningOnWindows) {
65+
return
66+
}
67+
68+
$signature = Get-AuthenticodeSignature -LiteralPath $File.FullName
69+
if ($signature.Status -ne "Valid") {
70+
$errors.Add("Microsoft runtime file $(Get-RelativePath -Root $payloadRoot -Path $File.FullName) has Authenticode status $($signature.Status).")
71+
return
72+
}
73+
74+
$subject = if ($signature.SignerCertificate) { $signature.SignerCertificate.Subject } else { "" }
75+
if ($subject -notmatch "O=Microsoft Corporation") {
76+
$errors.Add("Microsoft runtime file $(Get-RelativePath -Root $payloadRoot -Path $File.FullName) was not signed by Microsoft Corporation: $subject")
77+
}
78+
}
79+
80+
function Get-VCRuntimeFiles {
81+
param(
82+
[Parameter(Mandatory = $true)]
83+
[string]$Directory
84+
)
85+
86+
@(
87+
Get-ChildItem -LiteralPath $Directory -File -Filter "vcruntime140*.dll"
88+
Get-ChildItem -LiteralPath $Directory -File -Filter "msvcp140*.dll"
89+
Get-ChildItem -LiteralPath $Directory -File -Filter "concrt140.dll"
90+
) | Sort-Object FullName -Unique
91+
}
92+
93+
$libsodiumFiles = @(
94+
Get-ChildItem -LiteralPath $payloadRoot -Recurse -File -Filter libsodium.dll |
95+
Sort-Object FullName
96+
)
97+
98+
if ($libsodiumFiles.Count -eq 0) {
99+
$errors.Add("Missing libsodium.dll under $payloadRoot.")
100+
}
101+
102+
foreach ($libsodium in $libsodiumFiles) {
103+
$runtimePath = Join-Path $libsodium.DirectoryName "vcruntime140.dll"
104+
if ($RequireAppLocalVCRuntime -and -not (Test-Path -LiteralPath $runtimePath)) {
105+
$errors.Add("Missing app-local vcruntime140.dll next to $(Get-RelativePath -Root $payloadRoot -Path $libsodium.FullName).")
106+
}
107+
108+
if ($RequireAppLocalVCRuntime) {
109+
foreach ($runtimeFile in Get-VCRuntimeFiles -Directory $libsodium.DirectoryName) {
110+
Add-MicrosoftSignatureErrors -File $runtimeFile
111+
}
112+
}
113+
114+
if ($shouldProbeNativeLoad) {
115+
[OpenClawNativeDependencyProbe]::SetDllDirectory($libsodium.DirectoryName) | Out-Null
116+
Push-Location $libsodium.DirectoryName
117+
try {
118+
$handle = [OpenClawNativeDependencyProbe]::LoadLibrary("libsodium.dll")
119+
$lastError = [Runtime.InteropServices.Marshal]::GetLastWin32Error()
120+
} finally {
121+
Pop-Location
122+
}
123+
124+
if ($handle -eq [IntPtr]::Zero) {
125+
$errors.Add("libsodium.dll failed to load from $(Get-RelativePath -Root $payloadRoot -Path $libsodium.FullName) (Win32 error $lastError).")
126+
}
127+
}
128+
}
129+
130+
if ($RequireInstallerVCRedist) {
131+
$redist = if ([string]::IsNullOrWhiteSpace($InstallerVCRedistPath)) {
132+
Join-Path $payloadRoot "vc_redist.x64.exe"
133+
} else {
134+
$InstallerVCRedistPath
135+
}
136+
137+
if (-not (Test-Path -LiteralPath $redist)) {
138+
$errors.Add("Missing bundled Visual C++ Runtime redistributable at $redist.")
139+
} elseif ($runningOnWindows) {
140+
Add-MicrosoftSignatureErrors -File (Get-Item -LiteralPath $redist)
141+
}
142+
}
143+
144+
if ($errors.Count -gt 0) {
145+
$errors | ForEach-Object { Write-Error $_ }
146+
exit 1
147+
}
148+
149+
Write-Host "Release native dependency policy passed." -ForegroundColor Green

‎src/Directory.Build.props‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="GitVersion.MsBuild" Version="6.4.0" PrivateAssets="all" />
17+
<PackageReference Include="VCRuntime.CefSharp.140" Version="1.0.5" PrivateAssets="all" ExcludeAssets="build" />
1718
</ItemGroup>
1819

1920
</Project>

0 commit comments

Comments
 (0)