[CmdletBinding()]
param(
[Parameter(Mandatory)][ValidateSet('Loader','Standalone','Interaction','Validation','SessionRecovery','CruiseControl')][string]$Flavor,
[Parameter(Mandatory)][string]$OutputDirectory,
[string]$PackageDirectory,
[switch]$SkipPlatform,
[ValidateSet('Debug','Release')][string]$Configuration='Release'
)
$ErrorActionPreference='Stop'
$taskRoot=Split-Path -Parent $PSScriptRoot
# Kept for existing diagnostic callers; the project reference now builds the
# platform archive automatically, including when -SkipPlatform is supplied.
$taskProject=Join-Path $taskRoot ('native/ManagedPlugin/'+$Flavor+'/'+$Flavor+'.csproj')
$taskOutput=if([IO.Path]::IsPathRooted($OutputDirectory)){$OutputDirectory}else{Join-Path $taskRoot $OutputDirectory}
dotnet publish $taskProject -c $Configuration -r win-x64 -p:PublishAot=true -o $taskOutput --nologo
if($LASTEXITCODE -ne 0){throw "NativeAOT $Flavor build failed."}
if($Flavor -eq 'CruiseControl'){
$taskModule=Join-Path $taskOutput 'XFEEDInteraction.dll'
$taskPlatformSource=Get-Content -LiteralPath (Join-Path $taskRoot 'native/ManagedPlugin/Platform.cs') -Raw
$taskGameHash=[regex]::Match($taskPlatformSource,'const string GameHash = "([a-f0-9]{64})";')
if(-not $taskGameHash.Success){throw 'The verified game identity is missing from Platform.cs.'}
$taskManifest=Join-Path $taskOutput 'interaction.json'
@{schema=1;name='XFEEDToolBox.Interaction';file='XFEEDInteraction.dll';gameSha256=$taskGameHash.Groups[1].Value;sha256=(Get-FileHash -LiteralPath $taskModule -Algorithm SHA256).Hash.ToLowerInvariant()}|ConvertTo-Json|Set-Content -LiteralPath $taskManifest -Encoding utf8
if($PackageDirectory){
$taskPackage=if([IO.Path]::IsPathRooted($PackageDirectory)){[IO.Path]::GetFullPath($PackageDirectory)}else{[IO.Path]::GetFullPath((Join-Path $taskRoot $PackageDirectory))}
New-Item -ItemType Directory -Path $taskPackage -Force|Out-Null
if([IO.Path]::GetFullPath($taskOutput) -ne $taskPackage){Copy-Item -LiteralPath $taskModule,$taskManifest -Destination $taskPackage -Force}
}
}
[CmdletBinding()]
param(
[Parameter(Mandatory)][ValidateSet('Loader','Standalone','Interaction','Validation','SessionRecovery','CruiseControl')][string]$Flavor,
[Parameter(Mandatory)][string]$OutputDirectory,
[string]$PackageDirectory,
[switch]$SkipPlatform,
[ValidateSet('Debug','Release')][string]$Configuration='Release'
)
$ErrorActionPreference='Stop'
$taskRoot=Split-Path -Parent $PSScriptRoot
# Kept for existing diagnostic callers; the project reference now builds the
# platform archive automatically, including when -SkipPlatform is supplied.
$taskProject=Join-Path $taskRoot ('native/ManagedPlugin/'+$Flavor+'/'+$Flavor+'.csproj')
$taskOutput=if([IO.Path]::IsPathRooted($OutputDirectory)){$OutputDirectory}else{Join-Path $taskRoot $OutputDirectory}
dotnet publish $taskProject -c $Configuration -r win-x64 -p:PublishAot=true -o $taskOutput --nologo
if($LASTEXITCODE -ne 0){throw "NativeAOT $Flavor build failed."}
if($Flavor -eq 'CruiseControl'){
$taskModule=Join-Path $taskOutput 'XFEEDInteraction.dll'
$taskPlatformSource=Get-Content -LiteralPath (Join-Path $taskRoot 'native/ManagedPlugin/Platform.cs') -Raw
$taskGameHash=[regex]::Match($taskPlatformSource,'const string GameHash = "([a-f0-9]{64})";')
if(-not $taskGameHash.Success){throw 'The verified game identity is missing from Platform.cs.'}
$taskManifest=Join-Path $taskOutput 'interaction.json'
@{schema=1;name='XFEEDToolBox.Interaction';file='XFEEDInteraction.dll';gameSha256=$taskGameHash.Groups[1].Value;sha256=(Get-FileHash -LiteralPath $taskModule -Algorithm SHA256).Hash.ToLowerInvariant()}|ConvertTo-Json|Set-Content -LiteralPath $taskManifest -Encoding utf8
if($PackageDirectory){
$taskPackage=if([IO.Path]::IsPathRooted($PackageDirectory)){[IO.Path]::GetFullPath($PackageDirectory)}else{[IO.Path]::GetFullPath((Join-Path $taskRoot $PackageDirectory))}
New-Item -ItemType Directory -Path $taskPackage -Force|Out-Null
if([IO.Path]::GetFullPath($taskOutput) -ne $taskPackage){Copy-Item -LiteralPath $taskModule,$taskManifest -Destination $taskPackage -Force}
}
}