GHA and ADO pipeline updates (#623)

This commit is contained in:
Chuck Walbourn
2025-07-22 16:22:37 -07:00
committed by GitHub
parent 32b2a8ef35
commit 9a84cfdc5e
17 changed files with 585 additions and 310 deletions

20
build/RestoreGDK.proj Normal file
View File

@@ -0,0 +1,20 @@
<!-- First update the GDKEditionNumber property in gdkedition.props -->
<!-- nuget restore restoregdk.proj -packagesDirectory <outputdirectory> -->
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="gdkedition.props" />
<PropertyGroup>
<EditionYearMonth>$(GDKEditionNumber.Substring(0,2))$(GDKEditionNumber.Substring(2,2))</EditionYearMonth>
<EditionQFE>$(GDKEditionNumber.Substring(4,2).TrimStart('0'))</EditionQFE>
<EditionQFE Condition="'$(EditionQFE)'==''">0</EditionQFE>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.GDK.PC" Version="$(EditionYearMonth).$(EditionQFE).*" />
<PackageReference Include="Microsoft.GDK.Xbox" Version="$(EditionYearMonth).$(EditionQFE).*" />
</ItemGroup>
</Project>

159
build/RestoreGDK.ps1 Normal file
View File

@@ -0,0 +1,159 @@
<#
.SYNOPSIS
Download and extract GDK NuGet based on edition number
.DESCRIPTION
This script determines the NuGet package id to use based on the provided GDK edition number. It makes use of MSBuild PackageReference floating version numbers to do the restore operation.
.PARAMETER GDKEditionNumber
The GDK edition number in the form of YYMMQQ.
.PARAMETER OutputDirectory
Directory to write the packages into. Path should not already contain the packages.
#>
param(
[Parameter(
Mandatory,
Position = 0
)]
[string]$GDKEditionNumber,
[Parameter(
Mandatory,
Position = 1
)]
[string]$OutputDirectory
)
# Validate output directory
if ([string]::IsNullOrEmpty($OutputDirectory)) {
Write-Error "##[error]Output Directory is required" -ErrorAction Stop
}
# Parse edition number
if (-not ($GDKEditionNumber -match '^([0-9][0-9])([0-9][0-9])([0-9][0-9])$')) {
Write-Error "##[error]This script requires a valid GDK edition number!" -ErrorAction Stop
}
$year = $Matches.1
$month = [int]$Matches.2
$qfe = [int]$Matches.3
if ($year -lt 21)
{
Write-Error "##[error]Edition year not supported: 20$year" -ErrorAction Stop
}
if (($month -lt 1) -or ($month -gt 12))
{
Write-Error "##[error]Edition month not supported: $month" -ErrorAction Stop
}
if ($qfe -gt 0) {
Write-Host ("##[debug]GDKEditionNumber = $GDKEditionNumber ({0} 20{1} QFE {2})" -f (Get-Culture).DateTimeFormat.GetMonthName($month), $year, $qfe)
}
else {
Write-Host ("##[debug]GDKEditionNumber = $GDKEditionNumber ({0} 20{1})" -f (Get-Culture).DateTimeFormat.GetMonthName($month), $year)
}
# Verify NuGet tool is available
$nuget = Get-Command nuget.exe -ErrorAction SilentlyContinue
if (-Not $nuget) {
Write-Error "##[error]Missing required nuget.exe tool" -ErrorAction Stop
}
# Determine NuGet package ID
if ($GDKEditionNumber -ge 241000) {
$PGDK_ID = "Microsoft.GDK.PC"
$GDKX_ID = "Microsoft.GDK.Xbox"
}
else {
Write-Error "##[error]Script supports October 2024 or later" -ErrorAction Stop
}
# Check that the package isn't already present
$PGDK_DIR = [IO.Path]::Combine($OutputDirectory, $PGDK_ID)
if (Test-Path $PGDK_DIR) {
Write-Error "##[error]PC Package ID already exists!" -ErrorAction Stop
}
$GDKX_DIR = [IO.Path]::Combine($OutputDirectory, $GDKX_ID)
if (Test-Path $GDKX_DIR) {
Write-Error "##[error]Xbox Package ID already exists!" -ErrorAction Stop
}
# Restore Nuget packages using floating versions
$propsfile = [IO.Path]::Combine( $PSScriptRoot , "gdkedition.props")
$props = Get-Content -Path $propsfile
$props = $props -replace '<GDKEditionNumber>.+</GDKEditionNumber>', ("<GDKEditionNumber>{0}</GDKEditionNumber>" -f $GDKEditionNumber)
Set-Content -Path $propsfile -Value $props
$nugetArgs = "restore RestoreGDK.proj -PackageSaveMode nuspec -packagesDirectory `"{0}`"" -f $OutputDirectory.TrimEnd('\')
Write-Host "##[command]nuget $nugetArgs"
$nugetrun = Start-Process -PassThru -Wait -FilePath $nuget.Path -WorkingDirectory $PSScriptRoot -ArgumentList $nugetArgs -NoNewWindow
if ($nugetrun.ExitCode -gt 0) {
Write-Error "##[error]nuget restore failed" -ErrorAction Stop
}
# Verify expected output of restore
if (-Not (Test-Path $PGDK_DIR)) {
Write-Error "##[error]Missing PC package after restore!" -ErrorAction Stop
}
if (-Not (Test-Path $GDKX_DIR)) {
Write-Error "##[error]Missing Xbox package after restore!" -ErrorAction Stop
}
# Reduce path depth removing version folder
$PGDK_VER = Get-ChildItem $PGDK_DIR
if ($PGDK_VER.Count -ne 1) {
Write-Error "##[error]Expected a single directory for the version!" -ErrorAction Stop
}
$content = Get-ChildItem $PGDK_VER.Fullname
ForEach-Object -InputObject $content { Move-Item $_.Fullname -Destination $PGDK_DIR }
Remove-Item $PGDK_VER.Fullname
$GDKX_VER = Get-ChildItem $GDKX_DIR
if ($GDKX_VER.Count -ne 1) {
Write-Error "##[error]Expected a single directory for the version!" -ErrorAction Stop
}
$content = Get-ChildItem $GDKX_VER.Fullname
ForEach-Object -InputObject $content { Move-Item $_.Fullname -Destination $GDKX_DIR }
Remove-Item $GDKX_VER.Fullname
Write-Host ("##[debug]PC Package ID: {0} Version: {1}" -f $PGDK_ID, $PGDK_VER)
Write-Host ("##[debug]Xbox Package ID: {0} Version: {1}" -f $GDKX_ID, $GDKX_VER)
# Read the nuspec files
$PGDK_NUSPEC = New-Object xml
$PGDK_NUSPEC.PreserveWhitespace = $true
$PGDK_NUSPEC.Load([IO.Path]::Combine($PGDK_DIR, $PGDK_ID + ".nuspec"))
$GDKX_NUSPEC = New-Object xml
$GDKX_NUSPEC.PreserveWhitespace = $true
$GDKX_NUSPEC.Load([IO.Path]::Combine($GDKX_DIR, $GDKX_ID + ".nuspec"))
# Log results
Write-Host "##[group]PC Nuget Package nuspec"
Write-host $PGDK_NUSPEC.outerxml
Write-Host "##[endgroup]"
Write-Host "##[group]Xbox Nuget Package nuspec"
Write-host $GDKX_NUSPEC.outerxml
Write-Host "##[endgroup]"
$id = $PGDK_NUSPEC.package.metadata.id
Write-Host "##vso[task.setvariable variable=PCNuGetPackage;]$id"
$id = $GDKX_NUSPEC.package.metadata.id
Write-Host "##vso[task.setvariable variable=XboxNuGetPackage;]$id"
$ver = $PGDK_NUSPEC.package.metadata.version
Write-Host "##vso[task.setvariable variable=PCNuGetPackageVersion;]$ver"
$ver = $GDKX_NUSPEC.package.metadata.version
Write-Host "##vso[task.setvariable variable=XboxNuGetPackageVersion;]$ver"

View File

@@ -13,7 +13,7 @@ goto needconsole
set GXDKEDITION=%2
echo GXDKEDITION: %GXDKEDITION%
set PCNUGET=%1\Microsoft.GDK.PC.%GXDKEDITION%\
set PCNUGET=%1\Microsoft.GDK.PC\
if NOT EXIST %PCNUGET% goto missingpcnuget
set GRDKLatest=%PCNUGET%native\%GXDKEDITION%\GRDK\
@@ -21,7 +21,7 @@ echo GRDKLatest: %GRDKLatest%
if %3.==PC. goto grdkonly
set XBOXNUGET=%1\Microsoft.gdk.xbox.%GXDKEDITION%\
set XBOXNUGET=%1\Microsoft.gdk.xbox\
if NOT EXIST %XBOXNUGET% goto missingxboxnuget
set GXDKLatest=%XBOXNUGET%native\%GXDKEDITION%\GXDK\
@@ -68,9 +68,9 @@ echo Usage: This script requires the target type of PC, Scarlett, or XboxOne in
exit /b 1
:missingpcnuget
echo ERROR - Cannot find Microsoft.GDK.PC.<edition> installed at '%1'
echo ERROR - Cannot find Microsoft.GDK.PC installed at '%1'
exit /b 1
:missingxboxnuget
echo ERROR - Cannot find Microsoft.GDK.Xbox.<edition> installed at '%1'
echo ERROR - Cannot find Microsoft.GDK.Xbox installed at '%1'
exit /b 1

6
build/gdkedition.props Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<GDKEditionNumber>000000</GDKEditionNumber>
</PropertyGroup>
</Project>