37 lines
2.1 KiB
PowerShell
37 lines
2.1 KiB
PowerShell
param([string]$Feed = 'Artifacts/AgentSupport/packages')
|
|
$ErrorActionPreference = 'Stop'
|
|
$root = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '../..'))
|
|
$feedPath = [IO.Path]::GetFullPath((Join-Path $root $Feed))
|
|
New-Item -ItemType Directory -Force -Path $feedPath | Out-Null
|
|
$catalog = Get-Content (Join-Path $root 'Tools/Release/package-versions.json') -Raw | ConvertFrom-Json
|
|
$projects = @{}
|
|
foreach ($project in Get-ChildItem (Join-Path $root 'Assets/Modules') -Filter '*.csproj' -Recurse) {
|
|
if ($project.FullName -match '[\\/](obj|bin|Development~|Tools~|packages)[\\/]') { continue }
|
|
[xml]$xml = Get-Content $project.FullName -Raw
|
|
$id = @($xml.Project.PropertyGroup.PackageId | Where-Object { $_ })[0]
|
|
if ($id) { $projects[[string]$id] = $project.FullName }
|
|
}
|
|
foreach ($project in Get-ChildItem (Join-Path $root 'Godot/Packages') -Filter '*.csproj' -Recurse) {
|
|
[xml]$xml = Get-Content $project.FullName -Raw
|
|
$id = @($xml.Project.PropertyGroup.PackageId | Where-Object { $_ })[0]
|
|
if ($id) { $projects[[string]$id] = $project.FullName }
|
|
}
|
|
$projects['ShrinkSDK.Inspection'] = Join-Path $root 'Assets/ShrinkInspection/DotNet~/ShrinkSDK.Inspection.csproj'
|
|
$done = [Collections.Generic.HashSet[string]]::new()
|
|
$visiting = [Collections.Generic.HashSet[string]]::new()
|
|
function Build-Package([string]$id) {
|
|
if ($done.Contains($id)) { return }
|
|
if (-not $visiting.Add($id)) { throw "NuGet dependency cycle: $id" }
|
|
$project = $projects[$id]
|
|
[xml]$xml = Get-Content $project -Raw
|
|
foreach ($dependency in $xml.Project.ItemGroup.PackageReference) {
|
|
if ($dependency -and $projects.ContainsKey([string]$dependency.Include)) { Build-Package ([string]$dependency.Include) }
|
|
}
|
|
$log = Join-Path $feedPath "$id.pack.log"
|
|
& dotnet pack $project -c Release -o $feedPath "-p:RestoreSources=$feedPath" -p:NuGetAudit=false --nologo --verbosity quiet *> $log
|
|
if ($LASTEXITCODE -ne 0) { Get-Content $log -Tail 20; throw "Pack failed: $id" }
|
|
[void]$visiting.Remove($id); [void]$done.Add($id)
|
|
Write-Output "Packed $id"
|
|
}
|
|
foreach ($id in @($projects.Keys | Sort-Object)) { Build-Package $id }
|