Files
Genarrative/plugins/agc-unity-editor/dotnet/build.ps1
T
kdletters 3fc3399032
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Successful in 6m41s
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Successful in 7m8s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Successful in 7m16s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Successful in 7m38s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m11s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 3m11s
Project CI / Repository checks (pull_request) Successful in 4m22s
Project CI / Frontend tests (pull_request) Successful in 5m52s
Project CI / Native shell tests (pull_request) Successful in 9m52s
Project CI / Backend tests (pull_request) Successful in 11m3s
Project CI / AI game creator shell web tests (pull_request) Successful in 6m41s
接入 DotCraft Unity 编辑器插件
新增内置 Unity 插件与自包含 Attach helper,固定上游版本并保留许可证
统一 Runner 执行归属、项目身份校验、回执确认和不确定结果阻断
接入 Unity 工程导入、Agent 工具目录及 Windows 构建分发
补齐插件测试、CI 执行入口和 Windows .NET 10 工具链检查
记录真实 Unity 连接、执行、重载恢复及 Runner 边界验证
2026-09-18 19:44:36 +08:00

58 lines
4.3 KiB
PowerShell

param([ValidateSet('Debug', 'Release')][string]$Configuration = 'Release', [switch]$SkipTests)
$ErrorActionPreference = 'Stop'
if (![System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows)) {
throw 'Unity Attach 发布仅支持 Windows x64。'
}
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio/Installer/vswhere.exe'
if (!(Test-Path -LiteralPath $vswhere)) { throw '需要 Visual Studio C++ x64 构建工具。' }
$visualStudio = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if (!$visualStudio) { throw '需要 Visual Studio C++ x64 构建工具。' }
$vcvars = Join-Path $visualStudio 'VC/Auxiliary/Build/vcvars64.bat'
$nativeSource = Join-Path $PSScriptRoot 'vendor/Native/Bootstrap.cpp'
$nativeOutput = Join-Path $PSScriptRoot 'vendor/obj/native'
New-Item -ItemType Directory -Force -Path $nativeOutput | Out-Null
$command = 'call "{0}" >nul && cl /nologo /Brepro /LD /EHsc /MT /O2 "{1}" /Fo"{2}" /link /Brepro /OUT:"{3}" /IMPLIB:"{4}"' -f $vcvars,$nativeSource,(Join-Path $nativeOutput 'Bootstrap.obj'),(Join-Path $nativeOutput 'DotCraft.Unity.Native.dll'),(Join-Path $nativeOutput 'DotCraft.Unity.Native.lib')
& cmd.exe /d /c $command
if ($LASTEXITCODE -ne 0) { throw 'Unity Attach native bootstrap 构建失败。' }
if (!$SkipTests) {
& dotnet run --project (Join-Path $PSScriptRoot 'tests/Agc.Unity.Attach.Tests.csproj') -c $Configuration
if ($LASTEXITCODE -ne 0) { throw 'Unity Attach helper 测试失败。' }
}
$output = Join-Path $PSScriptRoot 'publish/win-x64'
& dotnet publish (Join-Path $PSScriptRoot 'Agc.Unity.Attach.csproj') -c $Configuration -r win-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -o $output
if ($LASTEXITCODE -ne 0) { throw 'Unity Attach helper 发布失败。' }
$licenses = Join-Path $output 'licenses'
New-Item -ItemType Directory -Force -Path $licenses | Out-Null
Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'vendor/LICENSE') -Destination (Join-Path $licenses 'DotCraft-Apache-2.0.txt')
Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'licenses/Roslyn-MIT.txt') -Destination $licenses
Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'NOTICE'),(Join-Path $PSScriptRoot 'THIRD-PARTY-NOTICES.txt') -Destination $output
Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'vendor/upstream.json') -Destination $licenses
$assets = Get-Content -LiteralPath (Join-Path $PSScriptRoot 'obj/project.assets.json') -Raw | ConvertFrom-Json
$runtime = @($assets.project.frameworks.PSObject.Properties | ForEach-Object { $_.Value.downloadDependencies } | Where-Object name -EQ 'Microsoft.NETCore.App.Runtime.win-x64' | Select-Object -Unique name, version)
if ($runtime.Count -ne 1) { throw '无法定位自包含 .NET runtime 许可。' }
$runtimeVersion = $runtime[0].version.Trim('[',']').Split(',')[0].Trim()
$runtimeDirectory = $null
foreach ($folder in $assets.packageFolders.PSObject.Properties.Name) {
$candidate = Join-Path $folder ('microsoft.netcore.app.runtime.win-x64/' + $runtimeVersion)
if (Test-Path -LiteralPath $candidate) { $runtimeDirectory = $candidate; break }
}
if (!$runtimeDirectory) { throw '无法定位自包含 .NET runtime 包。' }
foreach ($name in @('LICENSE.TXT', 'THIRD-PARTY-NOTICES.TXT')) {
$source = Join-Path $runtimeDirectory $name
if (!(Test-Path -LiteralPath $source)) { throw "缺少 .NET runtime 许可文件:$name" }
Copy-Item -LiteralPath $source -Destination (Join-Path $licenses ('dotnet-' + $name))
}
foreach ($package in @('microsoft.codeanalysis.common', 'microsoft.codeanalysis.csharp')) {
$notice = $null
foreach ($folder in $assets.packageFolders.PSObject.Properties.Name) {
$candidate = Join-Path $folder ($package + '/5.3.0/ThirdPartyNotices.rtf')
if (Test-Path -LiteralPath $candidate) { $notice = $candidate; break }
}
if (!$notice) { throw "缺少 Roslyn 第三方声明:$package" }
Copy-Item -LiteralPath $notice -Destination (Join-Path $licenses ($package + '-ThirdPartyNotices.rtf'))
}
$oldDebugFile = Join-Path $output 'DotCraft.Unity.Attach.pdb'
if (Test-Path -LiteralPath $oldDebugFile) { Remove-Item -LiteralPath $oldDebugFile }
if (!(Test-Path -LiteralPath (Join-Path $output 'Agc.Unity.Attach.exe'))) { throw '缺少 self-contained helper。' }
Write-Output "Unity Attach helper 已发布:$output"