55 lines
2.5 KiB
PowerShell
55 lines
2.5 KiB
PowerShell
param(
|
|
[string]$Configuration = 'Release',
|
|
[string]$OutputRoot = "$PSScriptRoot\..\ReplacedPerson.ServerHost\Mods\ExampleGreedMod",
|
|
[string]$ArtifactRoot = "$PSScriptRoot\..\..\Artifacts\ReplacedPersonMods"
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$sourceRoot = Resolve-Path "$PSScriptRoot\..\..\Assets\Demos\ReplacedPerson\Mods\ExampleGreedMod"
|
|
$project = "$PSScriptRoot\ExampleGreedMod.Rules.csproj"
|
|
dotnet build $project -c $Configuration
|
|
|
|
$resolvedOutput = [System.IO.Path]::GetFullPath($OutputRoot)
|
|
$expectedParent = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\ReplacedPerson.ServerHost\Mods")
|
|
if (-not $resolvedOutput.StartsWith($expectedParent, [System.StringComparison]::OrdinalIgnoreCase)) {
|
|
throw "OutputRoot must remain under $expectedParent"
|
|
}
|
|
if (Test-Path -LiteralPath $resolvedOutput) {
|
|
Remove-Item -LiteralPath $resolvedOutput -Recurse -Force
|
|
}
|
|
New-Item -ItemType Directory -Force -Path $resolvedOutput | Out-Null
|
|
|
|
$rulesDll = "$PSScriptRoot\bin\$Configuration\net8.0\ExampleGreedMod.Rules.dll"
|
|
Copy-Item -LiteralPath $rulesDll -Destination "$resolvedOutput\ExampleGreedMod.Rules.dll"
|
|
Copy-Item -LiteralPath "$sourceRoot\content.json" -Destination "$resolvedOutput\content.json"
|
|
Copy-Item -LiteralPath "$sourceRoot\icon.png" -Destination "$resolvedOutput\icon.png"
|
|
|
|
$unityDll = "$PSScriptRoot\..\..\Library\ScriptAssemblies\ExampleGreedMod.Unity.dll"
|
|
if (Test-Path -LiteralPath $unityDll) {
|
|
Copy-Item -LiteralPath $unityDll -Destination "$resolvedOutput\ExampleGreedMod.Unity.dll"
|
|
}
|
|
|
|
$files = Get-ChildItem -LiteralPath $resolvedOutput -File | Sort-Object Name | ForEach-Object {
|
|
[ordered]@{
|
|
path = $_.Name
|
|
sha256 = (Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
}
|
|
}
|
|
$manifest = [ordered]@{
|
|
id = 'example.greedy-training'
|
|
version = '1.0.0'
|
|
rulesAssembly = 'ExampleGreedMod.Rules.dll'
|
|
unityAssembly = if (Test-Path -LiteralPath "$resolvedOutput\ExampleGreedMod.Unity.dll") { 'ExampleGreedMod.Unity.dll' } else { $null }
|
|
content = 'content.json'
|
|
icon = 'icon.png'
|
|
networkCompatible = $true
|
|
files = @($files)
|
|
}
|
|
$manifest | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath "$resolvedOutput\manifest.json" -Encoding utf8
|
|
|
|
New-Item -ItemType Directory -Force -Path $ArtifactRoot | Out-Null
|
|
$zipPath = Join-Path $ArtifactRoot 'ExampleGreedMod-1.0.0.zip'
|
|
if (Test-Path -LiteralPath $zipPath) { Remove-Item -LiteralPath $zipPath -Force }
|
|
Compress-Archive -Path "$resolvedOutput\*" -DestinationPath $zipPath -CompressionLevel Optimal
|
|
Write-Output $zipPath
|