|
1 | | -# Local deployment script for ModVerify to test the update feature. |
2 | | -# This script builds the application, creates an update manifest, and "deploys" it to a local directory. |
| 1 | +# ========================================================================================= |
| 2 | +# Local deployment to test the ModVerify update flow end-to-end. |
| 3 | +# |
| 4 | +# USAGE |
| 5 | +# .\deploy-local.ps1 # single-channel test |
| 6 | +# .\deploy-local.ps1 -DualPublish # also publish to a next-gen channel |
| 7 | +# .\deploy-local.ps1 -DualPublish -CompatibilityUpdater <path> |
| 8 | +# # primary uses compat updater; |
| 9 | +# # next-gen uses build-output updater |
| 10 | +# |
| 11 | +# -CompatibilityUpdater requires -DualPublish. |
| 12 | +# -InstalledVersion / -ServerVersion override the version pair used to set up the test. |
| 13 | +# |
| 14 | +# Builds ModVerify twice (older "installed" + newer "server"), then hands off to the shared |
| 15 | +# Publish-LocalRelease.ps1 in ModdingToolBase for cert generation, manifest signing, and |
| 16 | +# install-dir staging. |
| 17 | +# ========================================================================================= |
| 18 | + |
| 19 | +param( |
| 20 | + [string]$InstalledVersion = "0.0.1-local", |
| 21 | + [string]$ServerVersion = "99.99.99-local", |
| 22 | + [switch]$DualPublish, |
| 23 | + [string]$CompatibilityUpdater |
| 24 | +) |
3 | 25 |
|
4 | 26 | $ErrorActionPreference = "Stop" |
5 | 27 |
|
6 | 28 | $root = $PSScriptRoot |
7 | 29 | if ([string]::IsNullOrEmpty($root)) { $root = Get-Location } |
8 | 30 |
|
9 | | -$deployRoot = Join-Path $root ".local_deploy" |
10 | | -$stagingDir = Join-Path $deployRoot "staging" |
11 | | -$serverDir = Join-Path $deployRoot "server" |
12 | | -$installDir = Join-Path $deployRoot "install" |
| 31 | +. (Join-Path $root "modules\ModdingToolBase\scripts\NbgvVersion.ps1") |
13 | 32 |
|
14 | | -$toolProj = Join-Path $root "src\ModVerify.CliApp\ModVerify.CliApp.csproj" |
15 | | -$creatorProj = Join-Path $root "modules\ModdingToolBase\src\AnakinApps\ApplicationManifestCreator\ApplicationManifestCreator.csproj" |
16 | | -$uploaderProj = Join-Path $root "modules\ModdingToolBase\src\AnakinApps\FtpUploader\FtpUploader.csproj" |
| 33 | +$deployRoot = Join-Path $root ".local_deploy" |
| 34 | +$installBuildDir = Join-Path $deployRoot "bin\install" |
| 35 | +$serverBuildDir = Join-Path $deployRoot "bin\tool" |
17 | 36 |
|
18 | | -$toolExe = "ModVerify.exe" |
19 | | -$updaterExe = "AnakinRaW.ExternalUpdater.exe" |
20 | | -$manifestCreatorDll = "AnakinRaW.ApplicationManifestCreator.dll" |
21 | | -$uploaderDll = "AnakinRaW.FtpUploader.dll" |
| 37 | +$toolProj = Join-Path $root "src\ModVerify.CliApp\ModVerify.CliApp.csproj" |
| 38 | +$baseScript = Join-Path $root "modules\ModdingToolBase\scripts\Publish-LocalRelease.ps1" |
22 | 39 |
|
23 | | -# 1. Clean and Create directories |
24 | 40 | if (Test-Path $deployRoot) { Remove-Item -Recurse -Force $deployRoot } |
25 | | -New-Item -ItemType Directory -Path $stagingDir | Out-Null |
26 | | -New-Item -ItemType Directory -Path $serverDir | Out-Null |
27 | | -New-Item -ItemType Directory -Path $installDir | Out-Null |
28 | | - |
29 | | -Write-Host "--- Building ModVerify (net481) ---" -ForegroundColor Cyan |
30 | | -dotnet build $toolProj --configuration Release -f net481 --output "$deployRoot\bin\tool" /p:DebugType=None /p:DebugSymbols=false |
31 | | - |
32 | | -Write-Host "--- Building Manifest Creator ---" -ForegroundColor Cyan |
33 | | -dotnet build $creatorProj --configuration Release --output "$deployRoot\bin\creator" |
34 | | - |
35 | | -Write-Host "--- Building Local Uploader ---" -ForegroundColor Cyan |
36 | | -dotnet build $uploaderProj --configuration Release --output "$deployRoot\bin\uploader" |
37 | | - |
38 | | -# 2. Prepare staging |
39 | | -Write-Host "--- Preparing Staging ---" -ForegroundColor Cyan |
40 | | -Copy-Item "$deployRoot\bin\tool\$toolExe" $stagingDir |
41 | | -Copy-Item "$deployRoot\bin\tool\$updaterExe" $stagingDir |
| 41 | +New-Item -ItemType Directory -Path $deployRoot | Out-Null |
42 | 42 |
|
43 | | -# 3. Create Manifest |
44 | | -# Origin must be an absolute URI for the manifest creator. |
45 | | -# Using 127.0.0.1 and file:// is tricky with Flurl/DownloadManager sometimes. |
46 | | -# We'll use the local path and ensure it's formatted correctly. |
47 | | -$serverPath = (Resolve-Path $serverDir).Path |
48 | | -$serverUri = "file:///$($serverPath.Replace('\', '/'))" |
49 | | -# If we have 3 slashes, Flurl/DownloadManager might still fail on Windows if it expects a certain format. |
50 | | -# However, the ManifestCreator just needs a valid URI for the 'Origin' field in the manifest. |
51 | | -Write-Host "--- Creating Manifest (Origin: $serverUri) ---" -ForegroundColor Cyan |
52 | | -dotnet "$deployRoot\bin\creator\$manifestCreatorDll" ` |
53 | | - -a "$stagingDir\$toolExe" ` |
54 | | - --appDataFiles "$stagingDir\$updaterExe" ` |
55 | | - --origin "$serverUri" ` |
56 | | - -o "$stagingDir" ` |
57 | | - -b "beta" |
| 43 | +$nbgv = Backup-NbgvVersion -RepoRoot $root |
| 44 | +try { |
| 45 | + Write-Host "--- Building ModVerify (net481) @ installed v$InstalledVersion ---" -ForegroundColor Cyan |
| 46 | + Set-NbgvVersion -Snapshot $nbgv -Version $InstalledVersion |
| 47 | + dotnet build $toolProj --configuration Release -f net481 --output $installBuildDir /p:DebugType=None /p:DebugSymbols=false /p:LocalDeploy=true |
58 | 48 |
|
59 | | -# 4. "Deploy" to server using the local uploader |
60 | | -Write-Host "--- Deploying to Local Server ---" -ForegroundColor Cyan |
61 | | -dotnet "$deployRoot\bin\uploader\$uploaderDll" local --base "$serverDir" --source "$stagingDir" |
| 49 | + Write-Host "--- Building ModVerify (net481) @ server v$ServerVersion ---" -ForegroundColor Cyan |
| 50 | + Set-NbgvVersion -Snapshot $nbgv -Version $ServerVersion |
| 51 | + dotnet build $toolProj --configuration Release -f net481 --output $serverBuildDir /p:DebugType=None /p:DebugSymbols=false /p:LocalDeploy=true |
62 | 52 |
|
63 | | -# 5. Setup a "test" installation |
64 | | -Write-Host "--- Setting up Test Installation ---" -ForegroundColor Cyan |
65 | | -Copy-Item "$deployRoot\bin\tool\*" $installDir -Recurse |
| 53 | + $publishParams = @{ |
| 54 | + AppExePath = Join-Path $serverBuildDir "ModVerify.exe" |
| 55 | + UpdaterExePath = Join-Path $serverBuildDir "AnakinRaW.ExternalUpdater.exe" |
| 56 | + DeployRoot = $deployRoot |
| 57 | + InstallBuildDir = $installBuildDir |
| 58 | + Branch = "beta" |
| 59 | + } |
| 60 | + if ($DualPublish) { $publishParams.DualPublish = $true } |
| 61 | + if ($CompatibilityUpdater) { $publishParams.CompatibilityUpdater = $CompatibilityUpdater } |
66 | 62 |
|
67 | | -Write-Host "`nLocal deployment complete!" -ForegroundColor Green |
68 | | -Write-Host "Server directory: $serverDir" |
69 | | -Write-Host "Install directory: $installDir" |
70 | | -Write-Host "`nTo test the update:" |
71 | | -Write-Host "1. (Optional) Modify the version in version.json and run this script again to 'push' a new version to the local server." |
72 | | -Write-Host "2. Run ModVerify from the install directory with the following command:" |
73 | | -Write-Host " cd '$installDir'" |
74 | | -Write-Host " .\ModVerify.exe updateApplication --updateManifestUrl '$serverUri'" |
75 | | -Write-Host "`n Note: You can also specify a different branch using --updateBranch if needed." |
| 63 | + & $baseScript @publishParams |
| 64 | +} |
| 65 | +finally { |
| 66 | + Restore-NbgvVersion -Snapshot $nbgv |
| 67 | +} |
0 commit comments