|
| 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. |
| 3 | + |
| 4 | +$ErrorActionPreference = "Stop" |
| 5 | + |
| 6 | +$root = $PSScriptRoot |
| 7 | +if ([string]::IsNullOrEmpty($root)) { $root = Get-Location } |
| 8 | + |
| 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" |
| 13 | + |
| 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" |
| 17 | + |
| 18 | +$toolExe = "ModVerify.exe" |
| 19 | +$updaterExe = "AnakinRaW.ExternalUpdater.exe" |
| 20 | +$manifestCreatorDll = "AnakinRaW.ApplicationManifestCreator.dll" |
| 21 | +$uploaderDll = "AnakinRaW.FtpUploader.dll" |
| 22 | + |
| 23 | +# 1. Clean and Create directories |
| 24 | +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 |
| 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" |
| 58 | + |
| 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" |
| 62 | + |
| 63 | +# 5. Setup a "test" installation |
| 64 | +Write-Host "--- Setting up Test Installation ---" -ForegroundColor Cyan |
| 65 | +Copy-Item "$deployRoot\bin\tool\*" $installDir -Recurse |
| 66 | + |
| 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." |
0 commit comments