From 4be213f20c02d16e4ee9221022776ad3d5cfe035 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 17 Jul 2025 16:38:05 -0700 Subject: [PATCH] Update GDK pipelines for latest packages --- .../DirectXTex-GitHub-CMake-Xbox-Dev17.yml | 49 +++--- .../DirectXTex-GitHub-CMake-Xbox.yml | 19 +-- .../pipelines/DirectXTex-GitHub-GDK-Dev17.yml | 47 +++--- .../pipelines/DirectXTex-GitHub-GDK.yml | 17 +- build/RestoreGDK.proj | 20 +++ build/RestoreGDK.ps1 | 159 ++++++++++++++++++ build/SetupBWOI.cmd | 8 +- build/gdkedition.props | 6 + 8 files changed, 247 insertions(+), 78 deletions(-) create mode 100644 build/RestoreGDK.proj create mode 100644 build/RestoreGDK.ps1 create mode 100644 build/gdkedition.props diff --git a/.azuredevops/pipelines/DirectXTex-GitHub-CMake-Xbox-Dev17.yml b/.azuredevops/pipelines/DirectXTex-GitHub-CMake-Xbox-Dev17.yml index e722331..46f39ec 100644 --- a/.azuredevops/pipelines/DirectXTex-GitHub-CMake-Xbox-Dev17.yml +++ b/.azuredevops/pipelines/DirectXTex-GitHub-CMake-Xbox-Dev17.yml @@ -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: diff --git a/.azuredevops/pipelines/DirectXTex-GitHub-CMake-Xbox.yml b/.azuredevops/pipelines/DirectXTex-GitHub-CMake-Xbox.yml index 2e27639..bb791e4 100644 --- a/.azuredevops/pipelines/DirectXTex-GitHub-CMake-Xbox.yml +++ b/.azuredevops/pipelines/DirectXTex-GitHub-CMake-Xbox.yml @@ -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: diff --git a/.azuredevops/pipelines/DirectXTex-GitHub-GDK-Dev17.yml b/.azuredevops/pipelines/DirectXTex-GitHub-GDK-Dev17.yml index e7663b4..46b213f 100644 --- a/.azuredevops/pipelines/DirectXTex-GitHub-GDK-Dev17.yml +++ b/.azuredevops/pipelines/DirectXTex-GitHub-GDK-Dev17.yml @@ -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: diff --git a/.azuredevops/pipelines/DirectXTex-GitHub-GDK.yml b/.azuredevops/pipelines/DirectXTex-GitHub-GDK.yml index c6a8dc1..e881639 100644 --- a/.azuredevops/pipelines/DirectXTex-GitHub-GDK.yml +++ b/.azuredevops/pipelines/DirectXTex-GitHub-GDK.yml @@ -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: diff --git a/build/RestoreGDK.proj b/build/RestoreGDK.proj new file mode 100644 index 0000000..512d0fc --- /dev/null +++ b/build/RestoreGDK.proj @@ -0,0 +1,20 @@ + + + + + + + + $(GDKEditionNumber.Substring(0,2))$(GDKEditionNumber.Substring(2,2)) + $(GDKEditionNumber.Substring(4,2).TrimStart('0')) + 0 + + + net472 + x64 + + + + + + diff --git a/build/RestoreGDK.ps1 b/build/RestoreGDK.ps1 new file mode 100644 index 0000000..93cafa1 --- /dev/null +++ b/build/RestoreGDK.ps1 @@ -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 '.+', ("{0}" -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" diff --git a/build/SetupBWOI.cmd b/build/SetupBWOI.cmd index 64ef0d4..f50ef7e 100644 --- a/build/SetupBWOI.cmd +++ b/build/SetupBWOI.cmd @@ -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. installed at '%1' +echo ERROR - Cannot find Microsoft.GDK.PC installed at '%1' exit /b 1 :missingxboxnuget -echo ERROR - Cannot find Microsoft.GDK.Xbox. installed at '%1' +echo ERROR - Cannot find Microsoft.GDK.Xbox installed at '%1' exit /b 1 diff --git a/build/gdkedition.props b/build/gdkedition.props new file mode 100644 index 0000000..36ae935 --- /dev/null +++ b/build/gdkedition.props @@ -0,0 +1,6 @@ + + + + 000000 + +