Skip to content

Commit 5f89a5e

Browse files
committed
Update GDK pipeline for package rename
1 parent b3c53a5 commit 5f89a5e

5 files changed

Lines changed: 225 additions & 54 deletions

File tree

.azuredevops/pipelines/DirectXTK12-GitHub-GDK-Dev17.yml

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ variables:
4646
value: false
4747
- name: EXTRACTED_FOLDER
4848
value: '$(ExtractedFolder)'
49+
- name: GDK_EDITION
50+
value: $(GDKEditionNumber)
4951
- name: GDKEnableBWOI
5052
value: true
5153
- name: URL_FEED
@@ -92,16 +94,13 @@ jobs:
9294
displayName: 'Secure Supply Chain Analysis'
9395
- task: NuGetAuthenticate@1
9496
displayName: 'NuGet Auth'
95-
- task: NuGetCommand@2
96-
displayName: NuGet install PGDK
97-
inputs:
98-
command: custom
99-
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
100-
- task: NuGetCommand@2
101-
displayName: NuGet install GDKX
97+
- task: PowerShell@2
98+
displayName: 'NuGet Install GDK'
10299
inputs:
103-
command: custom
104-
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
100+
targetType: filePath
101+
filePath: ./build/RestoreGDK.ps1
102+
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
103+
failOnStderr: true
105104
- task: CopyFiles@2
106105
displayName: Set up Directory.Build.props
107106
inputs:
@@ -155,16 +154,13 @@ jobs:
155154
displayName: 'Secure Supply Chain Analysis'
156155
- task: NuGetAuthenticate@1
157156
displayName: 'NuGet Auth'
158-
- task: NuGetCommand@2
159-
displayName: NuGet install PGDK
160-
inputs:
161-
command: custom
162-
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
163-
- task: NuGetCommand@2
164-
displayName: NuGet install GDKX
157+
- task: PowerShell@2
158+
displayName: 'NuGet Install GDK'
165159
inputs:
166-
command: custom
167-
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
160+
targetType: filePath
161+
filePath: ./build/RestoreGDK.ps1
162+
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
163+
failOnStderr: true
168164
- task: CmdLine@2
169165
displayName: Setup BWOI for GDK command-line
170166
inputs:
@@ -275,16 +271,13 @@ jobs:
275271
displayName: 'Secure Supply Chain Analysis'
276272
- task: NuGetAuthenticate@1
277273
displayName: 'NuGet Auth'
278-
- task: NuGetCommand@2
279-
displayName: NuGet install PGDK
280-
inputs:
281-
command: custom
282-
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
283-
- task: NuGetCommand@2
284-
displayName: NuGet install GDKX
274+
- task: PowerShell@2
275+
displayName: 'NuGet Install GDK'
285276
inputs:
286-
command: custom
287-
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
277+
targetType: filePath
278+
filePath: ./build/RestoreGDK.ps1
279+
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
280+
failOnStderr: true
288281
- task: CmdLine@2
289282
displayName: Setup BWOI for GDK command-line
290283
inputs:

.azuredevops/pipelines/DirectXTK12-GitHub-GDK.yml

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ variables:
6969
value: false
7070
- name: EXTRACTED_FOLDER
7171
value: '$(ExtractedFolder)'
72+
- name: GDK_EDITION
73+
value: $(GDKEditionNumber)
7274
- name: GDKEnableBWOI
7375
value: true
7476
- name: URL_FEED
@@ -113,16 +115,13 @@ jobs:
113115
displayName: 'Secure Supply Chain Analysis'
114116
- task: NuGetAuthenticate@1
115117
displayName: 'NuGet Auth'
116-
- task: NuGetCommand@2
117-
displayName: NuGet install PGDK
118-
inputs:
119-
command: custom
120-
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
121-
- task: NuGetCommand@2
122-
displayName: NuGet install GDKX
118+
- task: PowerShell@2
119+
displayName: 'NuGet Install GDK'
123120
inputs:
124-
command: custom
125-
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
121+
targetType: filePath
122+
filePath: ./build/RestoreGDK.ps1
123+
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
124+
failOnStderr: true
126125
- task: CopyFiles@2
127126
displayName: Set up Directory.Build.props
128127
inputs:
@@ -183,16 +182,13 @@ jobs:
183182
displayName: 'Secure Supply Chain Analysis'
184183
- task: NuGetAuthenticate@1
185184
displayName: 'NuGet Auth'
186-
- task: NuGetCommand@2
187-
displayName: NuGet install PGDK
188-
inputs:
189-
command: custom
190-
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
191-
- task: NuGetCommand@2
192-
displayName: NuGet install GDKX
185+
- task: PowerShell@2
186+
displayName: 'NuGet Install GDK'
193187
inputs:
194-
command: custom
195-
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
188+
targetType: filePath
189+
filePath: ./build/RestoreGDK.ps1
190+
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
191+
failOnStderr: true
196192
- task: NuGetCommand@2
197193
displayName: NuGet restore
198194
inputs:
@@ -276,16 +272,13 @@ jobs:
276272
displayName: 'Secure Supply Chain Analysis'
277273
- task: NuGetAuthenticate@1
278274
displayName: 'NuGet Auth'
279-
- task: NuGetCommand@2
280-
displayName: NuGet install PGDK
281-
inputs:
282-
command: custom
283-
arguments: install -prerelease Microsoft.GDK.PC.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
284-
- task: NuGetCommand@2
285-
displayName: NuGet install GDKX
275+
- task: PowerShell@2
276+
displayName: 'NuGet Install GDK'
286277
inputs:
287-
command: custom
288-
arguments: install -prerelease Microsoft.GDK.Xbox.$(GDK_EDITION) -ExcludeVersion -OutputDirectory $(EXTRACTED_FOLDER)
278+
targetType: filePath
279+
filePath: ./build/RestoreGDK.ps1
280+
arguments: -GDKEditionNumber $(GDK_EDITION) -OutputDirectory $(EXTRACTED_FOLDER)
281+
failOnStderr: true
289282
- task: NuGetCommand@2
290283
displayName: NuGet restore
291284
inputs:

build/RestoreGDK.proj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- First update the GDKEditionNumber property in gdkedition.props -->
2+
3+
<!-- nuget restore restoregdk.proj -packagesDirectory <outputdirectory> -->
4+
5+
<Project Sdk="Microsoft.NET.Sdk">
6+
<Import Project="gdkedition.props" />
7+
<PropertyGroup>
8+
<EditionYearMonth>$(GDKEditionNumber.Substring(0,2))$(GDKEditionNumber.Substring(2,2))</EditionYearMonth>
9+
<EditionQFE>$(GDKEditionNumber.Substring(4,2).TrimStart('0'))</EditionQFE>
10+
<EditionQFE Condition="'$(EditionQFE)'==''">0</EditionQFE>
11+
</PropertyGroup>
12+
<PropertyGroup>
13+
<TargetFramework>net472</TargetFramework>
14+
<Platforms>x64</Platforms>
15+
</PropertyGroup>
16+
<ItemGroup>
17+
<PackageReference Include="Microsoft.GDK.PC" Version="$(EditionYearMonth).$(EditionQFE).*" />
18+
<PackageReference Include="Microsoft.GDK.Xbox" Version="$(EditionYearMonth).$(EditionQFE).*" />
19+
</ItemGroup>
20+
</Project>

build/RestoreGDK.ps1

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<#
2+
3+
.SYNOPSIS
4+
Download and extract GDK NuGet based on edition number
5+
6+
.DESCRIPTION
7+
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.
8+
9+
.PARAMETER GDKEditionNumber
10+
The GDK edition number in the form of YYMMQQ.
11+
12+
.PARAMETER OutputDirectory
13+
Directory to write the packages into. Path should not already contain the packages.
14+
15+
#>
16+
17+
param(
18+
[Parameter(
19+
Mandatory,
20+
Position = 0
21+
)]
22+
[string]$GDKEditionNumber,
23+
[Parameter(
24+
Mandatory,
25+
Position = 1
26+
)]
27+
[string]$OutputDirectory
28+
)
29+
30+
# Validate output directory
31+
if ([string]::IsNullOrEmpty($OutputDirectory)) {
32+
Write-Error "##[error]Output Directory is required" -ErrorAction Stop
33+
}
34+
35+
# Parse edition number
36+
if (-not ($GDKEditionNumber -match '^([0-9][0-9])([0-9][0-9])([0-9][0-9])$')) {
37+
Write-Error "##[error]This script requires a valid GDK edition number!" -ErrorAction Stop
38+
}
39+
40+
$year = $Matches.1
41+
$month = [int]$Matches.2
42+
$qfe = [int]$Matches.3
43+
44+
if ($year -lt 21)
45+
{
46+
Write-Error "##[error]Edition year not supported: 20$year" -ErrorAction Stop
47+
}
48+
49+
if (($month -lt 1) -or ($month -gt 12))
50+
{
51+
Write-Error "##[error]Edition month not supported: $month" -ErrorAction Stop
52+
}
53+
54+
if ($qfe -gt 0) {
55+
Write-Host ("##[debug]GDKEditionNumber = $GDKEditionNumber ({0} 20{1} QFE {2})" -f (Get-Culture).DateTimeFormat.GetMonthName($month), $year, $qfe)
56+
}
57+
else {
58+
Write-Host ("##[debug]GDKEditionNumber = $GDKEditionNumber ({0} 20{1})" -f (Get-Culture).DateTimeFormat.GetMonthName($month), $year)
59+
}
60+
61+
# Verify NuGet tool is available
62+
$nuget = Get-Command nuget.exe -ErrorAction SilentlyContinue
63+
if (-Not $nuget) {
64+
Write-Error "##[error]Missing required nuget.exe tool" -ErrorAction Stop
65+
}
66+
67+
# Determine NuGet package ID
68+
if ($GDKEditionNumber -ge 241000) {
69+
$PGDK_ID = "Microsoft.GDK.PC"
70+
$GDKX_ID = "Microsoft.GDK.Xbox"
71+
}
72+
else {
73+
Write-Error "##[error]Script supports October 2024 or later" -ErrorAction Stop
74+
}
75+
76+
# Check that the package isn't already present
77+
$PGDK_DIR = [IO.Path]::Combine($OutputDirectory, $PGDK_ID)
78+
if (Test-Path $PGDK_DIR) {
79+
Write-Error "##[error]PC Package ID already exists!" -ErrorAction Stop
80+
}
81+
82+
$GDKX_DIR = [IO.Path]::Combine($OutputDirectory, $GDKX_ID)
83+
if (Test-Path $GDKX_DIR) {
84+
Write-Error "##[error]Xbox Package ID already exists!" -ErrorAction Stop
85+
}
86+
87+
# Restore Nuget packages using floating versions
88+
$propsfile = [IO.Path]::Combine( $PSScriptRoot , "gdkedition.props")
89+
$props = Get-Content -Path $propsfile
90+
$props = $props -replace '<GDKEditionNumber>.+</GDKEditionNumber>', ("<GDKEditionNumber>{0}</GDKEditionNumber>" -f $GDKEditionNumber)
91+
Set-Content -Path $propsfile -Value $props
92+
93+
$nugetArgs = "restore RestoreGDK.proj -PackageSaveMode nuspec -packagesDirectory `"{0}`"" -f $OutputDirectory.TrimEnd('\')
94+
Write-Host "##[command]nuget $nugetArgs"
95+
$nugetrun = Start-Process -PassThru -Wait -FilePath $nuget.Path -WorkingDirectory $PSScriptRoot -ArgumentList $nugetArgs -NoNewWindow
96+
if ($nugetrun.ExitCode -gt 0) {
97+
Write-Error "##[error]nuget restore failed" -ErrorAction Stop
98+
}
99+
100+
# Verify expected output of restore
101+
if (-Not (Test-Path $PGDK_DIR)) {
102+
Write-Error "##[error]Missing PC package after restore!" -ErrorAction Stop
103+
}
104+
105+
if (-Not (Test-Path $GDKX_DIR)) {
106+
Write-Error "##[error]Missing Xbox package after restore!" -ErrorAction Stop
107+
}
108+
109+
# Reduce path depth removing version folder
110+
$PGDK_VER = Get-ChildItem $PGDK_DIR
111+
if ($PGDK_VER.Count -ne 1) {
112+
Write-Error "##[error]Expected a single directory for the version!" -ErrorAction Stop
113+
}
114+
115+
$content = Get-ChildItem $PGDK_VER.Fullname
116+
ForEach-Object -InputObject $content { Move-Item $_.Fullname -Destination $PGDK_DIR }
117+
Remove-Item $PGDK_VER.Fullname
118+
119+
$GDKX_VER = Get-ChildItem $GDKX_DIR
120+
if ($GDKX_VER.Count -ne 1) {
121+
Write-Error "##[error]Expected a single directory for the version!" -ErrorAction Stop
122+
}
123+
124+
$content = Get-ChildItem $GDKX_VER.Fullname
125+
ForEach-Object -InputObject $content { Move-Item $_.Fullname -Destination $GDKX_DIR }
126+
Remove-Item $GDKX_VER.Fullname
127+
128+
Write-Host ("##[debug]PC Package ID: {0} Version: {1}" -f $PGDK_ID, $PGDK_VER)
129+
Write-Host ("##[debug]Xbox Package ID: {0} Version: {1}" -f $GDKX_ID, $GDKX_VER)
130+
131+
# Read the nuspec files
132+
$PGDK_NUSPEC = New-Object xml
133+
$PGDK_NUSPEC.PreserveWhitespace = $true
134+
$PGDK_NUSPEC.Load([IO.Path]::Combine($PGDK_DIR, $PGDK_ID + ".nuspec"))
135+
136+
$GDKX_NUSPEC = New-Object xml
137+
$GDKX_NUSPEC.PreserveWhitespace = $true
138+
$GDKX_NUSPEC.Load([IO.Path]::Combine($GDKX_DIR, $GDKX_ID + ".nuspec"))
139+
140+
# Log results
141+
Write-Host "##[group]PC Nuget Package nuspec"
142+
Write-host $PGDK_NUSPEC.outerxml
143+
Write-Host "##[endgroup]"
144+
145+
Write-Host "##[group]Xbox Nuget Package nuspec"
146+
Write-host $GDKX_NUSPEC.outerxml
147+
Write-Host "##[endgroup]"
148+
149+
$id = $PGDK_NUSPEC.package.metadata.id
150+
Write-Host "##vso[task.setvariable variable=PCNuGetPackage;]$id"
151+
152+
$id = $GDKX_NUSPEC.package.metadata.id
153+
Write-Host "##vso[task.setvariable variable=XboxNuGetPackage;]$id"
154+
155+
$ver = $PGDK_NUSPEC.package.metadata.version
156+
Write-Host "##vso[task.setvariable variable=PCNuGetPackageVersion;]$ver"
157+
158+
$ver = $GDKX_NUSPEC.package.metadata.version
159+
Write-Host "##vso[task.setvariable variable=XboxNuGetPackageVersion;]$ver"

build/gdkedition.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<GDKEditionNumber>000000</GDKEditionNumber>
5+
</PropertyGroup>
6+
</Project>

0 commit comments

Comments
 (0)