Repository navigation
Expand file tree
/
Copy pathpublish.ps1
More file actions
165 lines (150 loc) · 7.3 KB
/
Copy pathpublish.ps1
File metadata and controls
165 lines (150 loc) · 7.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
param(
[string]$Version = '0.03',
[switch]$RuntimeOnly
)
# Builds one self-contained Windows x64 release containing both applications:
# ThreeBrowser\ThreeBrowser.exe
# ThreeBrowserRuntime\ThreeBrowserRuntime.exe
$ErrorActionPreference = 'Stop'
$repo = $PSScriptRoot
$publishRoot = Join-Path $repo 'publish'
$packageName = if ($RuntimeOnly) { "ThreeRuntime-$Version-win-x64" } else { "ThreeBrowser-$Version-win-x64" }
$packageRoot = Join-Path $publishRoot $packageName
$browserOut = Join-Path $packageRoot 'ThreeBrowser'
$runtimeOut = Join-Path $packageRoot 'ThreeBrowserRuntime'
$zipPath = Join-Path $publishRoot "$packageName.zip"
$runtimeBin = Join-Path $repo 'ThreeBrowserRuntime\build\bin'
$nodeSource = (Get-Command node.exe -ErrorAction Stop).Source
function Remove-PublishTarget([string]$Target) {
if (-not (Test-Path -LiteralPath $Target)) { return }
$resolvedRoot = [IO.Path]::GetFullPath($publishRoot).TrimEnd('\')
$resolvedTarget = [IO.Path]::GetFullPath($Target).TrimEnd('\')
if ([string]::IsNullOrWhiteSpace($resolvedTarget) -or
-not $resolvedTarget.StartsWith($resolvedRoot + '\', [StringComparison]::OrdinalIgnoreCase)) {
throw "Refusing to remove a path outside the publish directory: $resolvedTarget"
}
$item = Get-Item -LiteralPath $resolvedTarget -Force -ErrorAction Stop
if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) {
throw "Refusing to remove a linked publish target: $resolvedTarget"
}
$linkedChild = Get-ChildItem -LiteralPath $resolvedTarget -Force -Recurse -ErrorAction Stop |
Where-Object { ($_.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0 } |
Select-Object -First 1
if ($null -ne $linkedChild) {
throw "Refusing to remove a publish tree containing a link: $($linkedChild.FullName)"
}
Remove-Item -LiteralPath $resolvedTarget -Recurse -Force -ErrorAction Stop
}
New-Item -ItemType Directory -Force -Path $publishRoot | Out-Null
Remove-PublishTarget $packageRoot
if (Test-Path -LiteralPath $zipPath -PathType Leaf) {
Remove-Item -LiteralPath $zipPath -Force -ErrorAction Stop
}
New-Item -ItemType Directory -Path $browserOut, $runtimeOut | Out-Null
if (-not $RuntimeOnly) {
Write-Host 'Publishing ThreeBrowser (self-contained win-x64)'
dotnet publish (Join-Path $repo 'host\ThreeBrowser\ThreeBrowser.csproj') `
-c Release -r win-x64 --self-contained true -o $browserOut
if ($LASTEXITCODE -ne 0) { throw 'ThreeBrowser publish failed.' }
}
Write-Host 'Publishing ThreeBrowserRuntime (self-contained win-x64)'
dotnet publish (Join-Path $repo 'ThreeBrowserRuntime\ThreeBrowserRuntime.csproj') `
-c Release -r win-x64 --self-contained true -o $runtimeOut
if ($LASTEXITCODE -ne 0) { throw 'ThreeBrowserRuntime publish failed.' }
if (-not (Test-Path -LiteralPath (Join-Path $runtimeBin 'runtime\launch.mjs') -PathType Leaf)) {
throw 'The staged native runtime is missing runtime\launch.mjs.'
}
# The native build is staged outside MSBuild's normal publish item graph.
$packagedRuntimeBin = Join-Path $runtimeOut 'build\bin'
New-Item -ItemType Directory -Force -Path $packagedRuntimeBin | Out-Null
Copy-Item -LiteralPath (Join-Path $runtimeBin 'runtime') -Destination $packagedRuntimeBin -Recurse -Force
Copy-Item -LiteralPath (Join-Path $runtimeBin 'demo') -Destination $packagedRuntimeBin -Recurse -Force
$runtimePayloadFiles = @(
'glslangValidator.exe',
'libgcc_s_seh-1.dll',
'libstdc++-6.dll',
'libwinpthread-1.dll',
'NvLowLatencyVk.dll',
'nvngx_dlss.dll',
'nvngx_dlssd.dll',
'nvngx_dlssg.dll',
'sl.common.dll',
'sl.dlss_d.dll',
'sl.dlss_g.dll',
'sl.dlss.dll',
'sl.interposer.dll',
'sl.pcl.dll',
'sl.reflex.dll',
'three_browser_runtime.node',
'three_native.dll',
'three_webgpu.dll',
'wgpu_native.dll'
)
foreach ($fileName in $runtimePayloadFiles) {
$source = Join-Path $runtimeBin $fileName
if (-not (Test-Path -LiteralPath $source -PathType Leaf)) {
throw "Native runtime payload missing: $source"
}
Copy-Item -LiteralPath $source -Destination $packagedRuntimeBin -Force
}
$vcRuntimeFiles = @('msvcp140.dll', 'vcruntime140.dll', 'vcruntime140_1.dll')
foreach ($fileName in $vcRuntimeFiles) {
$source = Join-Path ([Environment]::GetFolderPath('System')) $fileName
if (-not (Test-Path -LiteralPath $source -PathType Leaf)) {
throw "Microsoft VC++ runtime dependency missing: $source"
}
Copy-Item -LiteralPath $source -Destination $packagedRuntimeBin -Force
}
Copy-Item -LiteralPath (Join-Path $repo 'ThreeBrowserRuntime\samples') -Destination $runtimeOut -Recurse -Force
Copy-Item -LiteralPath (Join-Path $repo 'ThreeBrowserRuntime\node_modules') -Destination $runtimeOut -Recurse -Force
Copy-Item -LiteralPath $nodeSource -Destination (Join-Path $runtimeOut 'node.exe') -Force
Copy-Item -LiteralPath (Join-Path $repo 'LICENSE') -Destination (Join-Path $packageRoot 'LICENSE.txt') -Force
Copy-Item -LiteralPath (Join-Path $repo 'THIRD_PARTY.md') -Destination (Join-Path $packageRoot 'THIRD_PARTY.md') -Force
$readme = @"
ThreeBrowser $Version - Windows x64
ThreeBrowser\ThreeBrowser.exe
Browser host with WebView2 and native Three.js/WebGPU rendering.
ThreeBrowserRuntime\ThreeBrowserRuntime.exe
WebView-free native project importer and launcher. Node.js is bundled for
the JavaScript execution host; no separate Node installation is required.
Both applications require 64-bit Windows. The launcher UI uses the Microsoft
WebView2 Evergreen Runtime, included with Windows 11 and available separately
for supported Windows versions.
"@
if ($RuntimeOnly) {
$readme = @"
ThreeRuntime $Version - Windows x64
Launch ThreeBrowserRuntime\ThreeBrowserRuntime.exe.
Node.js and the .NET runtime are bundled. The launcher UI requires Microsoft
WebView2 Evergreen Runtime, included with Windows 11.
Native scene execution uses DirectGL or WebGPU; browser DOM parity is incomplete.
"@
}
Set-Content -LiteralPath (Join-Path $packageRoot 'README.txt') -Value $readme -Encoding utf8
$requiredFiles = @(
(Join-Path $browserOut 'ThreeBrowser.exe'),
(Join-Path $browserOut 'three_native.dll'),
(Join-Path $browserOut 'three_webgpu.dll'),
(Join-Path $browserOut 'wgpu_native.dll'),
(Join-Path $runtimeOut 'ThreeBrowserRuntime.exe'),
(Join-Path $runtimeOut 'node.exe'),
(Join-Path $packagedRuntimeBin 'three_browser_runtime.node'),
(Join-Path $packagedRuntimeBin 'three_native.dll'),
(Join-Path $packagedRuntimeBin 'three_webgpu.dll'),
(Join-Path $packagedRuntimeBin 'wgpu_native.dll'),
(Join-Path $packagedRuntimeBin 'glslangValidator.exe'),
(Join-Path $packagedRuntimeBin 'msvcp140.dll'),
(Join-Path $packagedRuntimeBin 'vcruntime140.dll'),
(Join-Path $packagedRuntimeBin 'vcruntime140_1.dll'),
(Join-Path $packagedRuntimeBin 'runtime\launch.mjs')
)
if ($RuntimeOnly) { $requiredFiles = $requiredFiles | Where-Object { -not $_.StartsWith($browserOut + '\', [StringComparison]::OrdinalIgnoreCase) } }
foreach ($required in $requiredFiles) {
if (-not (Test-Path -LiteralPath $required -PathType Leaf)) {
throw "Release dependency missing: $required"
}
}
Compress-Archive -Path (Join-Path $packageRoot '*') -DestinationPath $zipPath -CompressionLevel Optimal
$hash = (Get-FileHash -LiteralPath $zipPath -Algorithm SHA256).Hash
Write-Host "Package: $zipPath"
Write-Host "SHA-256: $hash"