Files
bd2/plugins/GameSdk/Pack.ps1
T
Flechazo 992fa47fd5 feat(all): add game SDK and harden client login and game rules
- Add costume burst upgrades with durable replay and fix permanent SR equipment gacha.
- Add server game.json rules for optional collaboration UR weapons, with packaging and documentation.
- Add GameNames/GameSdk NuGet tooling, readable types, reobfuscation, complete source/PDB navigation and shared-runtime installation.
- Split plugin responsibilities, prefer typeof/nameof, centralize MSBuild settings and ignore local paths; remove the unused LoginUI test project.
- Fix login recovery and TLS through native platform HTTP and a private game relay; read device region directly from the OS time zone.

Validation: go test ./... -count=1, go vet ./..., plugin Release builds, SDK/runtime self-tests, Roslyn embedded-source navigation, gofmt check and git diff --check.
2026-10-03 23:04:32 +08:00

56 lines
3.5 KiB
PowerShell

[CmdletBinding()]
param(
[Parameter(Mandatory)] [string]$GameDir,
[string]$VersionConfig,
[string]$PackageVersion,
[string]$OutputDirectory
)
$ErrorActionPreference = 'Stop'
if (-not $VersionConfig) { $VersionConfig = Join-Path $PSScriptRoot '..\..\versions.json' }
if (-not $OutputDirectory) { $OutputDirectory = Join-Path $PSScriptRoot '..\..\.build\nuget' }
$repository = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..'))
$versions = Get-Content -LiteralPath $VersionConfig -Raw | ConvertFrom-Json
if (-not $PackageVersion) {
[xml]$metadata = Get-Content -LiteralPath (Join-Path $PSScriptRoot '..\PackageMetadata.props') -Raw
$PackageVersion = "$($metadata.Project.PropertyGroup.BD2PackageVersion)-game.$($versions.game_version)"
}
if ($PackageVersion -notmatch '^\d+\.\d+\.\d+-game\.\d+\.\d+\.\d+(?:\.[A-Za-z0-9-]+)*$') {
throw 'PackageVersion must be SemVer with game version, for example 0.2.1-game.2.35.10.'
}
if ($PackageVersion -notmatch ('-game\.' + [regex]::Escape([string]$versions.game_version) + '(?:\.|$)')) {
throw 'PackageVersion game suffix must match VersionConfig game_version.'
}
$OutputDirectory = [IO.Path]::GetFullPath($OutputDirectory)
$staging = Join-Path $repository ".build\nuget-staging\$PackageVersion"
$sdk = Join-Path $staging 'sdk'
$tool = Join-Path $staging 'tool'
$runtimeObj = Join-Path $staging 'runtime-obj'
$runtimeBin = Join-Path $staging 'runtime-bin'
$packageObj = Join-Path $staging 'package-obj'
$packageBin = Join-Path $staging 'package-bin'
New-Item -ItemType Directory -Force -Path $OutputDirectory, $staging | Out-Null
function Invoke-Dotnet([string[]]$Arguments) {
& dotnet @Arguments
if ($LASTEXITCODE -ne 0) { throw "dotnet failed with exit code $LASTEXITCODE" }
}
$toolVersion = $PackageVersion.Split('-')[0]
Invoke-Dotnet @('publish', (Join-Path $PSScriptRoot 'GameSdk.csproj'), '-c', 'Release', '--nologo', '-o', $tool, "-p:Version=$toolVersion", '-p:UseAppHost=false')
$assembly = Join-Path $GameDir 'BrownDust II_Data\Managed\Assembly-CSharp.dll'
$toolDll = Join-Path $tool 'GameSdk.dll'
Invoke-Dotnet @($toolDll, 'prepare-embedded', $assembly, $sdk, $VersionConfig)
$table = Join-Path $sdk 'names.json'
$runtimeProject = Join-Path $PSScriptRoot '..\GameNames\GameNames.csproj'
Invoke-Dotnet @('pack', $runtimeProject, '-c', 'Release', '--nologo', '-o', $OutputDirectory,
"-p:Version=$PackageVersion", "-p:GameNamesTable=$table", "-p:BaseIntermediateOutputPath=$runtimeObj/", "-p:OutputPath=$runtimeBin/")
Invoke-Dotnet @($toolDll, 'verify-runtime', $table, (Join-Path $runtimeBin 'BD2.GameNames.dll'))
$packageProject = Join-Path $PSScriptRoot 'Package\BD2.GameSdk.Package.csproj'
$nugetConfig = Join-Path $staging 'NuGet.Config'
$escapedSource = [Security.SecurityElement]::Escape($OutputDirectory)
[IO.File]::WriteAllText($nugetConfig, "<configuration><packageSources><clear/><add key=`"bd2-local`" value=`"$escapedSource`"/><add key=`"nuget.org`" value=`"https://api.nuget.org/v3/index.json`"/></packageSources></configuration>")
Invoke-Dotnet @('restore', $packageProject, '--configfile', $nugetConfig, "-p:Version=$PackageVersion",
'-p:BD2Packaging=true', "-p:BaseIntermediateOutputPath=$packageObj/", "-p:OutputPath=$packageBin/")
Invoke-Dotnet @('pack', $packageProject, '-c', 'Release', '--no-restore', '--nologo', '-o', $OutputDirectory,
"-p:Version=$PackageVersion", "-p:BD2ToolPublishDir=$tool", '-p:BD2Packaging=true',
"-p:BaseIntermediateOutputPath=$packageObj/", "-p:OutputPath=$packageBin/")
Write-Host "Created BD2.GameNames and BD2.GameSdk $PackageVersion in $OutputDirectory"