-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add New CI Pipeline for Latest WindowsAppSDK (#36282)
This PR introduces the following changes to the CI pipeline and version management: Pipeline Enhancements: 1. Added a new script UpdateVersions.ps1 to automate the update of Microsoft.WindowsAppSDK versions across various project files. 2. Introduced a new pipeline configuration ci-using-the-latest-winappsdk.yml to build using the latest Microsoft.WindowsAppSDK. 3. Updated existing pipeline configurations to support the new useLatestWinAppSDK parameter. Pipeline Configuration Updates: 1. Updated job-build-project.yml to handle the useLatestWinAppSDK parameter and adjust the RestoreAdditionalProjectSourcesArg accordingly. 2. Added a new template steps-update-winappsdk-and-restore-nuget.yml for updating and restoring NuGet packages with the latest Microsoft.WindowsAppSDK. 3. Added WinAPPSDK version selection, the pipeline can be manually triggered to use the specified version. --------- Signed-off-by: Shawn Yuan <[email protected]> Co-authored-by: Clint Rutkas <[email protected]>
- Loading branch information
1 parent
43bc811
commit ea66066
Showing
6 changed files
with
298 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1845,5 +1845,5 @@ zonable | |
zoneset | ||
Zoneszonabletester | ||
zzz | ||
|
||
|
||
localpackage | ||
winappsdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
Param( | ||
# Using the default value of 1.6 for winAppSdkVersionNumber and useExperimentalVersion as false | ||
[Parameter(Mandatory=$False,Position=1)] | ||
[string]$winAppSdkVersionNumber = "1.6", | ||
|
||
# When the pipeline calls the PS1 file, the passed parameters are converted to string type | ||
[Parameter(Mandatory=$False,Position=2)] | ||
[boolean]$useExperimentalVersion = $False | ||
) | ||
|
||
function Update-NugetConfig { | ||
param ( | ||
[string]$filePath = "nuget.config" | ||
) | ||
|
||
Write-Host "Updating nuget.config file" | ||
[xml]$xml = Get-Content -Path $filePath | ||
|
||
# Add localpackages source into nuget.config | ||
$packageSourcesNode = $xml.configuration.packageSources | ||
$addNode = $xml.CreateElement("add") | ||
$addNode.SetAttribute("key", "localpackages") | ||
$addNode.SetAttribute("value", "localpackages") | ||
$packageSourcesNode.AppendChild($addNode) | Out-Null | ||
|
||
# Remove <packageSourceMapping> tag and its content | ||
$packageSourceMappingNode = $xml.configuration.packageSourceMapping | ||
if ($packageSourceMappingNode) { | ||
$xml.configuration.RemoveChild($packageSourceMappingNode) | Out-Null | ||
} | ||
|
||
# print nuget.config after modification | ||
$xml.OuterXml | ||
# Save the modified nuget.config file | ||
$xml.Save($filePath) | ||
} | ||
|
||
$sourceLink = "https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json" | ||
|
||
# Execute nuget list and capture the output | ||
if ($useExperimentalVersion) { | ||
# The nuget list for experimental versions will cost more time | ||
# So, we will not use -AllVersions to wast time | ||
# But it can only get the latest experimental version | ||
Write-Host "Fetching WindowsAppSDK with experimental versions" | ||
$nugetOutput = nuget list Microsoft.WindowsAppSDK ` | ||
-Source $sourceLink ` | ||
-Prerelease | ||
# Filter versions based on the specified version prefix | ||
$escapedVersionNumber = [regex]::Escape($winAppSdkVersionNumber) | ||
$filteredVersions = $nugetOutput | Where-Object { $_ -match "Microsoft.WindowsAppSDK $escapedVersionNumber\." } | ||
$latestVersions = $filteredVersions | ||
} else { | ||
Write-Host "Fetching stable WindowsAppSDK versions for $winAppSdkVersionNumber" | ||
$nugetOutput = nuget list Microsoft.WindowsAppSDK ` | ||
-Source $sourceLink ` | ||
-AllVersions | ||
# Filter versions based on the specified version prefix | ||
$escapedVersionNumber = [regex]::Escape($winAppSdkVersionNumber) | ||
$filteredVersions = $nugetOutput | Where-Object { $_ -match "Microsoft.WindowsAppSDK $escapedVersionNumber\." } | ||
$latestVersions = $filteredVersions | Sort-Object { [version]($_ -split ' ')[1] } -Descending | Select-Object -First 1 | ||
} | ||
|
||
Write-Host "Latest versions found: $latestVersions" | ||
# Extract the latest version number from the output | ||
$latestVersion = $latestVersions -split "`n" | ` | ||
Select-String -Pattern 'Microsoft.WindowsAppSDK\s*([0-9]+\.[0-9]+\.[0-9]+-*[a-zA-Z0-9]*)' | ` | ||
ForEach-Object { $_.Matches[0].Groups[1].Value } | ` | ||
Sort-Object -Descending | ` | ||
Select-Object -First 1 | ||
|
||
if ($latestVersion) { | ||
$WinAppSDKVersion = $latestVersion | ||
Write-Host "Extracted version: $WinAppSDKVersion" | ||
Write-Host "##vso[task.setvariable variable=WinAppSDKVersion]$WinAppSDKVersion" | ||
} else { | ||
Write-Host "Failed to extract version number from nuget list output" | ||
exit 1 | ||
} | ||
|
||
# Update packages.config files | ||
Get-ChildItem -Recurse packages.config | ForEach-Object { | ||
$content = Get-Content $_.FullName -Raw | ||
if ($content -match 'package id="Microsoft.WindowsAppSDK"') { | ||
$newVersionString = 'package id="Microsoft.WindowsAppSDK" version="' + $WinAppSDKVersion + '"' | ||
$oldVersionString = 'package id="Microsoft.WindowsAppSDK" version="[-.0-9a-zA-Z]*"' | ||
$content = $content -replace $oldVersionString, $newVersionString | ||
Set-Content -Path $_.FullName -Value $content | ||
Write-Host "Modified " $_.FullName | ||
} | ||
} | ||
|
||
# Update Directory.Packages.props file | ||
$propsFile = "Directory.Packages.props" | ||
if (Test-Path $propsFile) { | ||
$content = Get-Content $propsFile -Raw | ||
if ($content -match '<PackageVersion Include="Microsoft.WindowsAppSDK"') { | ||
$newVersionString = '<PackageVersion Include="Microsoft.WindowsAppSDK" Version="' + $WinAppSDKVersion + '" />' | ||
$oldVersionString = '<PackageVersion Include="Microsoft.WindowsAppSDK" Version="[-.0-9a-zA-Z]*" />' | ||
$content = $content -replace $oldVersionString, $newVersionString | ||
Set-Content -Path $propsFile -Value $content | ||
Write-Host "Modified " $propsFile | ||
} | ||
} | ||
|
||
# Update .vcxproj files | ||
Get-ChildItem -Recurse *.vcxproj | ForEach-Object { | ||
$content = Get-Content $_.FullName -Raw | ||
if ($content -match '\\Microsoft.WindowsAppSDK.') { | ||
$newVersionString = '\Microsoft.WindowsAppSDK.' + $WinAppSDKVersion + '\' | ||
$oldVersionString = '\\Microsoft.WindowsAppSDK.[-.0-9a-zA-Z]*\\' | ||
$content = $content -replace $oldVersionString, $newVersionString | ||
Set-Content -Path $_.FullName -Value $content | ||
Write-Host "Modified " $_.FullName | ||
} | ||
} | ||
|
||
# Update .csproj files | ||
Get-ChildItem -Recurse *.csproj | ForEach-Object { | ||
$content = Get-Content $_.FullName -Raw | ||
if ($content -match 'PackageReference Include="Microsoft.WindowsAppSDK"') { | ||
$newVersionString = 'PackageReference Include="Microsoft.WindowsAppSDK" Version="'+ $WinAppSDKVersion + '"' | ||
$oldVersionString = 'PackageReference Include="Microsoft.WindowsAppSDK" Version="[-.0-9a-zA-Z]*"' | ||
$content = $content -replace $oldVersionString, $newVersionString | ||
Set-Content -Path $_.FullName -Value $content | ||
Write-Host "Modified " $_.FullName | ||
} | ||
} | ||
|
||
Update-NugetConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
trigger: none | ||
pr: none | ||
schedules: | ||
- cron: "0 0 * * *" # every day at midnight | ||
displayName: "Daily midnight Build" | ||
branches: | ||
include: | ||
- main | ||
always: false # only run if there's code changes! | ||
|
||
name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr) | ||
|
||
parameters: | ||
- name: buildPlatforms | ||
type: object | ||
default: | ||
- x64 | ||
- arm64 | ||
- name: enableMsBuildCaching | ||
type: boolean | ||
displayName: "Enable MSBuild Caching" | ||
default: false | ||
- name: runTests | ||
type: boolean | ||
displayName: "Run Tests" | ||
default: true | ||
- name: useVSPreview | ||
type: boolean | ||
displayName: "Build Using Visual Studio Preview" | ||
default: false | ||
- name: useLatestWinAppSDK | ||
type: boolean | ||
default: true | ||
- name: winAppSDKVersionNumber | ||
type: string | ||
default: 1.6 | ||
- name: useExperimentalVersion | ||
type: boolean | ||
default: false | ||
|
||
extends: | ||
template: templates/pipeline-ci-build.yml | ||
parameters: | ||
buildPlatforms: ${{ parameters.buildPlatforms }} | ||
enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} | ||
runTests: ${{ parameters.runTests }} | ||
useVSPreview: ${{ parameters.useVSPreview }} | ||
useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }} | ||
winAppSDKVersionNumber: ${{ parameters.winAppSDKVersionNumber }} | ||
useExperimentalVersion: ${{ parameters.useExperimentalVersion }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.