1- # Assemble a release zip.
1+ # Assemble a release zip.
22#
33# The build output directory is not the release: it also holds import libraries, export files, debug
44# symbols, and whatever earlier experiments left behind. Shipping that folder wholesale is how a
99# and the user supplies their own copy per game folder. Only the ~108 KB forwarder ships.
1010
1111param (
12- [ValidatePattern ( ' ^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$ ' )][ string ]$Version = " v0.1.0-dlssnr" ,
12+ [string ]$Version = " v0.1.0-dlssnr" ,
1313 [switch ]$SkipBuild
1414)
1515
@@ -19,57 +19,20 @@ $ErrorActionPreference = "Stop"
1919# than one now -- the experiment runs in a git worktree beside the main tree, and a hardcoded root
2020# silently packages the other one's build output while reporting success.
2121$root = Split-Path - Parent $PSCommandPath
22- . (Join-Path $root ' dist\runtime_sync\Aurora_Common.ps1' )
23- function Copy-PackageFile ([string ]$Source , [string ]$Target ) {
24- $current = ' ' ; if (Test-Path - LiteralPath $Target ) { $current = Get-AuroraHash $Target }
25- Copy-AuroraAtomic $Source $Target $current (Get-AuroraHash $Source )
26- }
27- function Copy-PackageTree ([string ]$Source , [string ]$Target ) {
28- $guard = Enter-AuroraPathGuard $Source - Directory
29- try {
30- foreach ($item in @ (Get-ChildItem - LiteralPath $Source - Force)) {
31- Assert-AuroraPlainPath $item.FullName
32- if ($item.PSIsContainer ) {
33- if ($item.Name -match ' ^(AuroraSetup|RuntimeSync|_storage.*|\.git)$' ) { continue }
34- if ($item.Name -ieq ' plugins' ) {
35- $patcher = Join-Path $item.FullName ' OptiPatcher.asi'
36- if (Test-Path - LiteralPath $patcher ) { Copy-PackageFile $patcher (Join-Path $Target ' plugins\OptiPatcher.asi' ) }
37- continue
38- }
39- Copy-PackageTree $item.FullName (Join-Path $Target $item.Name )
40- } elseif ($item.Name -notmatch ' (?i)\.(exp|lib|pdb|ilk)$|latewarp' ) {
41- Copy-PackageFile $item.FullName (Join-Path $Target $item.Name )
42- }
43- }
44- } finally { $guard.Dispose () }
45- }
4622$msb = " C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"
47- $releaseRoot = Join-Path $root ' release'
48- # Fresh stages avoid recursive deletion entirely; failed stages remain inspectable.
49- $stage = Join-Path $releaseRoot ($Version + ' -' + [Guid ]::NewGuid().ToString(' N' ))
50- $zip = Join-Path $releaseRoot (" OptiScaler-DLSSNR-$Version .zip" )
51- foreach ($path in @ ($stage , $zip )) {
52- if (-not (Test-AuroraWithin $path $releaseRoot )) { throw ' Package output escaped release directory.' }
53- Assert-AuroraPlainPath $path
54- }
55- $releaseGuard = Enter-AuroraPathGuard $releaseRoot - Directory - Create
56- try {
23+ $stage = " $root \release\$Version "
24+ $zip = " $root \release\OptiScaler-DLSSNR-$Version .zip"
5725
5826if (-not $SkipBuild ) {
5927 foreach ($proj in @ (" $root \OptiScaler\dlssnr\forwarder\dlssnr_forwarder.vcxproj" , " $root \OptiScaler.sln" )) {
6028 $out = & $msb $proj / p:Configuration= Release / p:Platform= x64 / v:minimal / m 2>&1
6129 $err = $out | Select-String " error "
62- if ($LASTEXITCODE -ne 0 -or $ err ) { throw " Build failed : $proj (exit $LASTEXITCODE ): $ ( $out -join [ Environment ]::NewLine ) " }
30+ if ($err ) { Write-Host " FAILED : $proj " ; $err | Select-Object - First 6 ; exit 1 }
6331 }
6432 Write-Host " built"
6533}
6634
6735$src = " $root \x64\Release\a"
68- foreach ($name in @ (' OptiScaler.dll' , ' OptiScaler.ini' )) { $null = Get-AuroraHash (Join-Path $src $name ) }
69- foreach ($name in @ (' Licenses' , ' OptiScaler' )) {
70- $path = Join-Path $src $name ; Assert-AuroraPlainPath $path
71- if (-not (Test-Path - LiteralPath $path - PathType Container)) { throw " Missing package directory: $name " }
72- }
7336
7437# The forwarder is taken from its own build output, not from the shared folder. The solution build
7538# does not reliably rebuild it, and a stale one here would ship silently.
@@ -79,13 +42,12 @@ foreach ($name in @('Licenses','OptiScaler')) {
7942# guards against a stale one, and it runs either way.
8043$forwarder = " $root \OptiScaler\dlssnr\forwarder\x64\Release\a\nvngx.dll_dlssnr.dll"
8144
82- if (-not (Test-Path - LiteralPath $forwarder )) {
45+ if (-not (Test-Path $forwarder )) {
8346 $forwarder = " $root \x64\Release\a\nvngx.dll_dlssnr.dll"
8447 Write-Host " forwarder: using the shared build output ($forwarder )"
8548}
8649
8750$exports = @ (" dlssnr_call_create" , " dlssnr_call_evaluate" , " dlssnr_call_set_extras" )
88- $null = Get-AuroraHash $forwarder
8951$bytes = [System.Text.Encoding ]::ASCII.GetString([System.IO.File ]::ReadAllBytes($forwarder ))
9052$missing = @ ($exports | Where-Object { $bytes.IndexOf ($_ ) -lt 0 })
9153
@@ -94,7 +56,8 @@ if ($missing.Count -gt 0) {
9456 exit 1
9557}
9658
97- [IO.Directory ]::CreateDirectory($stage ) | Out-Null
59+ if (Test-Path $stage ) { Remove-Item $stage - Recurse - Force }
60+ New-Item - ItemType Directory - Force - Path $stage | Out-Null
9861
9962# Files, then folders. Anything not named here does not ship.
10063$files = @ (
@@ -107,18 +70,23 @@ $files = @(
10770)
10871
10972foreach ($f in $files ) {
110- if (Test-Path - LiteralPath " $src \$f " ) { Copy-PackageFile " $src \$f " " $stage \$f " }
73+ if (Test-Path " $src \$f " ) { Copy-Item " $src \$f " " $stage \$f " - Force }
11174 else { Write-Host " missing from build output: $f " }
11275}
11376
114- foreach ($d in @ (" Licenses" , " OptiScaler" )) {
115- Copy-PackageTree " $src \$d " " $stage \$d "
77+ # Always stage the current setup helpers together; runtime_sync.ps1 now shares Aurora_Common.ps1.
78+ foreach ($name in @ (' Aurora_Common.ps1' , ' Aurora_Diagnostics.ps1' , ' Aurora_Setup.ps1' , ' runtime_sync.ps1' ,
79+ ' Aurora_Setup.bat' , ' Check_DLSS_Runtime.bat' , ' Remove_Aurora.bat' )) {
80+ $helper = Join-Path $root (" dist\runtime_sync\" + $name )
81+ if (-not (Test-Path - LiteralPath $helper - PathType Leaf)) { throw " Missing Aurora helper: $name " }
82+ Copy-Item - LiteralPath $helper - Destination (Join-Path $stage $name ) - Force
11683}
11784
118- # Source helpers, wrapper, DLSS and catalog-verified SL2 are refreshed together.
119- & (Join-Path $root ' scripts\stage_aurora_package.ps1' ) - RepositoryRoot $root - Destination $stage
85+ foreach ($d in @ (" Licenses" , " OptiScaler" )) {
86+ Copy-Item " $src \$d " " $stage \$d " - Recurse - Force
87+ }
12088
121- Copy-PackageFile $forwarder " $stage \nvngx.dll_dlssnr.dll"
89+ Copy-Item $forwarder " $stage \nvngx.dll_dlssnr.dll" - Force
12290
12391# Logging on, in the release only.
12492#
@@ -131,25 +99,25 @@ Copy-PackageFile $forwarder "$stage\nvngx.dll_dlssnr.dll"
13199# answers the common report at almost no cost. Crash reports need Trace and synchronous writes, and
132100# the notes say so rather than everyone paying for it.
133101$iniPath = " $stage \OptiScaler.ini"
134- $ini = Get-Content - LiteralPath $iniPath - Raw
102+ $ini = Get-Content $iniPath - Raw
135103$ini = $ini -replace ' (?m)^LogToFile=auto' , ' LogToFile=true'
136104$ini = $ini -replace ' (?m)^LogLevel=auto' , ' LogLevel=2'
137- Set-Content - LiteralPath $iniPath $ini - Encoding utf8 - NoNewline
105+ Set-Content $iniPath $ini - Encoding utf8 - NoNewline
138106
139- $check = Select-String - LiteralPath $iniPath - Pattern ' ^LogToFile=|^LogLevel=' | ForEach-Object { $_.Line }
107+ $check = Select-String - Path $iniPath - Pattern ' ^LogToFile=|^LogLevel=' | ForEach-Object { $_.Line }
140108Write-Host " log settings: $ ( $check -join ' , ' ) "
141109
142110# Belt and braces: nothing that is a build artifact, and nothing from the abandoned warp work, may
143111# survive into the zip regardless of how it got into the staging folder.
144- # Build artifacts and installation state were excluded during the guarded copy.
112+ Get-ChildItem $stage - Recurse - Include * .exp , * .lib , * .pdb , * .ilk , * latewarp * | Remove-Item - Force
145113
146114# No feature may ship switched on by accident.
147115#
148116# A global regex on "^Enabled=auto" once turned on five sections at once -- output scaling,
149117# sharpening, the magnifier and two more -- while trying to enable one, because the ini has six keys
150118# called Enabled in six different sections. That was in a test install rather than a release, and
151119# only because nothing was checking. This checks.
152- $on = Select-String - LiteralPath " $stage \OptiScaler.ini" - Pattern ' ^Enabled=true'
120+ $on = Select-String - Path " $stage \OptiScaler.ini" - Pattern ' ^Enabled=true'
153121
154122if ($on ) {
155123 Write-Host " REFUSING: the packaged ini has features switched on:"
@@ -159,16 +127,11 @@ if ($on) {
159127
160128Write-Host " ini verified: nothing switched on by default"
161129
162- & (Join-Path $root ' scripts\stage_aurora_package.ps1' ) - RepositoryRoot $root - Destination $stage - VerifyOnly
163- Add-Type - AssemblyName System.IO.Compression.FileSystem
164- $temporaryZip = Join-Path $releaseRoot ([Guid ]::NewGuid().ToString(' N' )+ ' .zip' )
165- [IO.Compression.ZipFile ]::CreateFromDirectory($stage , $temporaryZip , ' Optimal' , $false )
166- Copy-PackageFile $temporaryZip $zip
167- [IO.File ]::Delete($temporaryZip )
130+ if (Test-Path $zip ) { Remove-Item $zip - Force }
131+ Compress-Archive - Path " $stage \*" - DestinationPath $zip - CompressionLevel Optimal
168132
169133Write-Host " "
170134Write-Host " staged at $stage "
171- Get-ChildItem - LiteralPath $stage | ForEach-Object { Write-Host ( ' ' + $_.Name ) }
135+ Get-ChildItem $stage | ForEach-Object { " {0,-42} {1,10:N0} " -f $_.Name , $_ .Length }
172136Write-Host " "
173- Write-Host (" zip: {0} ({1:N1} MB)" -f $zip , ((Get-Item - LiteralPath $zip ).Length / 1 MB ))
174- } finally { $releaseGuard.Dispose () }
137+ Write-Host (" zip: {0} ({1:N1} MB)" -f $zip , ((Get-Item $zip ).Length / 1 MB ))
0 commit comments