Update GDK pipelines for latest packages

This commit is contained in:
Chuck Walbourn 2025-07-17 16:38:05 -07:00
parent afafeba900
commit 4be213f20c
8 changed files with 247 additions and 78 deletions

View File

@ -51,12 +51,14 @@ variables:
value: '10.0.19041.0'
- name: EXTRACTED_FOLDER
value: '$(ExtractedFolder)'
- name: GDK_EDITION
value: $(GDKEditionNumber)
- name: URL_FEED
value: $(ADOFeedURL)
- name: VC_PATH
value: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC'
- name: GameDKLatest
value: '$(ExtractedFolder)\Microsoft.gdk.xbox.$(GDK_EDITION)\native\$(GDK_EDITION)\'
value: '$(ExtractedFolder)\Microsoft.gdk.xbox\native\$(GDK_EDITION)\'
- name: skipNugetSecurityAnalysis
value: true # We explicitly call this task so we don't need it to be auto-injected
@ -97,16 +99,13 @@ jobs:
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
- task: PowerShell@2
displayName: 'NuGet Install GDK'
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
targetType: filePath
filePath: ./build/RestoreGDK.ps1
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
failOnStderr: true
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 (Xbox Series X|S)'
inputs:
@ -251,16 +250,13 @@ jobs:
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
- task: PowerShell@2
displayName: 'NuGet Install GDK'
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
targetType: filePath
filePath: ./build/RestoreGDK.ps1
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
failOnStderr: true
- task: CmdLine@2
displayName: Setup BWOI for GDK command-line
inputs:
@ -345,16 +341,13 @@ jobs:
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
- task: PowerShell@2
displayName: 'NuGet Install GDK'
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
targetType: filePath
filePath: ./build/RestoreGDK.ps1
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
failOnStderr: true
- task: CmdLine@2
displayName: Setup BWOI for GDK command-line
inputs:

View File

@ -63,10 +63,12 @@ variables:
value: '10.0.19041.0'
- name: EXTRACTED_FOLDER
value: '$(ExtractedFolder)'
- name: GDK_EDITION
value: $(GDKEditionNumber)
- name: URL_FEED
value: $(ADOFeedURL)
- name: GameDKLatest
value: '$(ExtractedFolder)\Microsoft.gdk.xbox.$(GDK_EDITION)\native\$(GDK_EDITION)\'
value: '$(ExtractedFolder)\Microsoft.gdk.xbox\native\$(GDK_EDITION)\'
- name: skipNugetSecurityAnalysis
value: true # We explicitly call this task so we don't need it to be auto-injected
@ -107,16 +109,13 @@ jobs:
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
- task: PowerShell@2
displayName: 'NuGet Install GDK'
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
targetType: filePath
filePath: ./build/RestoreGDK.ps1
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
failOnStderr: true
- task: CMake@1
displayName: 'CMake (MSVC): Config x64 (Xbox Series X|S)'
inputs:

View File

@ -47,6 +47,8 @@ variables:
value: false
- name: EXTRACTED_FOLDER
value: '$(ExtractedFolder)'
- name: GDK_EDITION
value: $(GDKEditionNumber)
- name: GDKEnableBWOI
value: true
- name: URL_FEED
@ -92,16 +94,13 @@ jobs:
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
- task: PowerShell@2
displayName: 'NuGet Install GDK'
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
targetType: filePath
filePath: ./build/RestoreGDK.ps1
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
failOnStderr: true
- task: CopyFiles@2
displayName: Set up Directory.Build.props
inputs:
@ -155,16 +154,13 @@ jobs:
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
- task: PowerShell@2
displayName: 'NuGet Install GDK'
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
targetType: filePath
filePath: ./build/RestoreGDK.ps1
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
failOnStderr: true
- task: CmdLine@2
displayName: Setup BWOI for GDK command-line
inputs:
@ -274,16 +270,13 @@ jobs:
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
- task: PowerShell@2
displayName: 'NuGet Install GDK'
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
targetType: filePath
filePath: ./build/RestoreGDK.ps1
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
failOnStderr: true
- task: CmdLine@2
displayName: Setup BWOI for GDK command-line
inputs:

View File

@ -66,6 +66,8 @@ variables:
value: false
- name: EXTRACTED_FOLDER
value: '$(ExtractedFolder)'
- name: GDK_EDITION
value: $(GDKEditionNumber)
- name: GDKEnableBWOI
value: true
- name: URL_FEED
@ -109,16 +111,13 @@ jobs:
displayName: 'Secure Supply Chain Analysis'
- task: NuGetAuthenticate@1
displayName: 'NuGet Auth'
- task: NuGetCommand@2
displayName: NuGet install PGDK
- task: PowerShell@2
displayName: 'NuGet Install GDK'
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
- task: NuGetCommand@2
displayName: NuGet install GDKX
inputs:
command: custom
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
targetType: filePath
filePath: ./build/RestoreGDK.ps1
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
failOnStderr: true
- task: CopyFiles@2
displayName: Set up Directory.Build.props
inputs:

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 2010 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
$args = "restore RestoreGDK.proj -PackageSaveMode nuspec -packagesDirectory `"{0}`"" -f $OutputDirectory.TrimEnd('\')
Write-Host "##[command]nuget $args"
$nugetrun = Start-Process -PassThru -Wait -FilePath $nuget.Path -WorkingDirectory $PSScriptRoot -ArgumentList $args -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>