diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 573e24c5cc..a2887579c1 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -1845,5 +1845,5 @@ zonable zoneset Zoneszonabletester zzz - - +localpackage +winappsdk diff --git a/.pipelines/UpdateVersions.ps1 b/.pipelines/UpdateVersions.ps1 new file mode 100644 index 0000000000..c19dfb5dec --- /dev/null +++ b/.pipelines/UpdateVersions.ps1 @@ -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 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 '' + $oldVersionString = '' + $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 diff --git a/.pipelines/v2/ci-using-the-latest-winappsdk.yml b/.pipelines/v2/ci-using-the-latest-winappsdk.yml new file mode 100644 index 0000000000..cc9f00f80d --- /dev/null +++ b/.pipelines/v2/ci-using-the-latest-winappsdk.yml @@ -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 }} diff --git a/.pipelines/v2/templates/job-build-project.yml b/.pipelines/v2/templates/job-build-project.yml index ff082d3537..653e8cc9fd 100644 --- a/.pipelines/v2/templates/job-build-project.yml +++ b/.pipelines/v2/templates/job-build-project.yml @@ -56,6 +56,15 @@ parameters: - name: versionNumber type: string default: '0.0.1' + - name: useLatestWinAppSDK + type: boolean + default: false + - name: winAppSDKVersionNumber + type: string + default: 1.6 + - name: useExperimentalVersion + type: boolean + default: false - name: csProjectsToPublish type: object default: @@ -102,6 +111,10 @@ jobs: ${{ else }}: MSBuildMainBuildTargets: Build ${{ insert }}: ${{ parameters.variables }} + ${{ if eq(parameters.useLatestWinAppSDK, true) }}: + RestoreAdditionalProjectSourcesArg: '/p:RestoreAdditionalProjectSources="$(Build.SourcesDirectory)\localpackages\NugetPackages"' + ${{ else }}: + RestoreAdditionalProjectSourcesArg: '' displayName: Build timeoutInMinutes: 240 cancelTimeoutInMinutes: 1 @@ -182,8 +195,15 @@ jobs: "packages.config" | "$(Agent.OS)" "packages.config" path: packages - - - template: .\steps-restore-nuget.yml + + - ${{ if eq(parameters.useLatestWinAppSDK, true)}}: + - template: .\steps-update-winappsdk-and-restore-nuget.yml + parameters: + versionNumber: ${{ parameters.winAppSDKVersionNumber }} + useExperimentalVersion: ${{ parameters.useExperimentalVersion }} + + - ${{ if eq(parameters.useLatestWinAppSDK, false)}}: + - template: .\steps-restore-nuget.yml - pwsh: |- & "$(build.sourcesdirectory)\.pipelines\verifyAndSetLatestVCToolsVersion.ps1" @@ -214,6 +234,7 @@ jobs: ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) /t:$(MSBuildMainBuildTargets) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -238,10 +259,11 @@ jobs: inputs: solution: '**\HostsUILib.csproj' vsVersion: 17.0 - ${{ if eq(parameters.useVSPreview, true) }}: - msbuildArgs: /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-hosts.binlog /p:NoWarn=NU5104 - ${{ else }}: - msbuildArgs: /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-hosts.binlog + msbuildArgs: >- + /p:CIBuild=true;NoBuild=true -t:pack + /bl:$(LogOutputDirectory)\build-hosts.binlog + /p:NoWarn=NU5104 + $(RestoreAdditionalProjectSourcesArg) configuration: $(BuildConfiguration) msbuildArchitecture: x64 maximumCpuCount: true @@ -254,10 +276,11 @@ jobs: inputs: solution: '**\EnvironmentVariablesUILib.csproj' vsVersion: 17.0 - ${{ if eq(parameters.useVSPreview, true) }}: - msbuildArgs: /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-env-var-editor.binlog /p:NoWarn=NU5104 - ${{ else }}: - msbuildArgs: /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-env-var-editor.binlog + msbuildArgs: >- + /p:CIBuild=true;NoBuild=true -t:pack + /bl:$(LogOutputDirectory)\build-env-var-editor.binlog + /p:NoWarn=NU5104 + $(RestoreAdditionalProjectSourcesArg) configuration: $(BuildConfiguration) msbuildArchitecture: x64 maximumCpuCount: true @@ -270,10 +293,11 @@ jobs: inputs: solution: '**\RegistryPreviewUILib.csproj' vsVersion: 17.0 - ${{ if eq(parameters.useVSPreview, true) }}: - msbuildArgs: /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-registry-preview.binlog /p:NoWarn=NU5104 - ${{ else }}: - msbuildArgs: /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-registry-preview.binlog + msbuildArgs: >- + /p:CIBuild=true;NoBuild=true -t:pack + /bl:$(LogOutputDirectory)\build-registry-preview.binlog + /p:NoWarn=NU5104 + $(RestoreAdditionalProjectSourcesArg) configuration: $(BuildConfiguration) msbuildArchitecture: x64 maximumCpuCount: true @@ -328,6 +352,7 @@ jobs: /bl:$(LogOutputDirectory)\build-bug-report.binlog ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -348,6 +373,7 @@ jobs: /bl:$(LogOutputDirectory)\build-webcam-report.binlog ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -368,6 +394,7 @@ jobs: /bl:$(LogOutputDirectory)\build-styles-report.binlog ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -390,6 +417,7 @@ jobs: /p:PowerToysRoot=$(Build.SourcesDirectory) /p:PublishProfile=InstallationPublishProfile.pubxml /bl:$(LogOutputDirectory)\publish-${{ join('_',split(project, '/')) }}.binlog + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -419,9 +447,11 @@ jobs: & '.pipelines/verifyPossibleAssetConflicts.ps1' -targetDir '$(build.sourcesdirectory)\$(BuildPlatform)\$(BuildConfiguration)\WinUI3Apps' displayName: Audit WinAppSDK applications path asset conflicts - - pwsh: |- - & '.pipelines/verifyNoticeMdAgainstNugetPackages.ps1' -path '$(build.sourcesdirectory)\' - displayName: Verify NOTICE.md and NuGet packages match + # To streamline the pipeline and prevent errors, skip this step during compatibility tests with the latest WinAppSDK. + - ${{ if eq(parameters.useLatestWinAppSDK, false) }}: + - pwsh: |- + & '.pipelines/verifyNoticeMdAgainstNugetPackages.ps1' -path '$(build.sourcesdirectory)\' + displayName: Verify NOTICE.md and NuGet packages match - ${{ if eq(parameters.runTests, true) }}: # Publish test results which ran in MSBuild diff --git a/.pipelines/v2/templates/pipeline-ci-build.yml b/.pipelines/v2/templates/pipeline-ci-build.yml index 71ebd6a33b..b7db8a7ae1 100644 --- a/.pipelines/v2/templates/pipeline-ci-build.yml +++ b/.pipelines/v2/templates/pipeline-ci-build.yml @@ -22,6 +22,15 @@ parameters: - name: useVSPreview type: boolean default: false + - name: useLatestWinAppSDK + type: boolean + default: false + - name: winAppSDKVersionNumber + type: string + default: 1.6 + - name: useExperimentalVersion + type: boolean + default: false stages: # Allow manual builds to skip pre-check @@ -55,6 +64,10 @@ stages: enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} runTests: ${{ parameters.runTests }} useVSPreview: ${{ parameters.useVSPreview }} + useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }} + ${{ if eq(parameters.useLatestWinAppSDK, true) }}: + winAppSDKVersionNumber: ${{ parameters.winAppSDKVersionNumber }} + useExperimentalVersion: ${{ parameters.useExperimentalVersion }} - ${{ if eq(parameters.runTests, true) }}: - stage: Test_${{ platform }} diff --git a/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml b/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml new file mode 100644 index 0000000000..1fccd6de74 --- /dev/null +++ b/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml @@ -0,0 +1,56 @@ +parameters: + - name: versionNumber + type: string + default: 1.6 + - name: useExperimentalVersion + type: boolean + default: false + +steps: +- task: NuGetAuthenticate@1 + displayName: 'NuGet Authenticate' + +- task: PowerShell@2 + displayName: Update WinAppSDK Versions + inputs: + filePath: '$(build.sourcesdirectory)\.pipelines\UpdateVersions.ps1' + arguments: > + -winAppSdkVersionNumber ${{ parameters.versionNumber }} + -useExperimentalVersion $${{ parameters.useExperimentalVersion }} + +- script: echo $(WinAppSDKVersion) + displayName: 'Display WinAppSDK Version Found' + +- task: DownloadPipelineArtifact@2 + displayName: 'Download WindowsAppSDK' + inputs: + buildType: 'specific' + project: '55e8140e-57ac-4e5f-8f9c-c7c15b51929d' + definition: '104083' + buildVersionToDownload: 'latestFromBranch' + branchName: 'refs/heads/release/${{ parameters.versionNumber }}-stable' + artifactName: 'WindowsAppSDK_Nuget_And_MSIX' + targetPath: '$(Build.SourcesDirectory)\localpackages' + +- script: dir $(Build.SourcesDirectory)\localpackages\NugetPackages + displayName: 'List downloaded packages' + +- task: NuGetCommand@2 + displayName: 'Install WindowsAppSDK' + inputs: + command: 'custom' + arguments: > + install "Microsoft.WindowsAppSDK" + -Source "$(Build.SourcesDirectory)\localpackages\NugetPackages" + -Version "$(WinAppSDKVersion)" + -OutputDirectory "$(Build.SourcesDirectory)\localpackages\output" + -FallbackSource "https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json" + +- task: NuGetCommand@2 + displayName: 'Restore NuGet packages' + inputs: + command: 'restore' + feedsToUse: 'config' + nugetConfigPath: '$(build.sourcesdirectory)\nuget.config' + restoreSolution: '$(build.sourcesdirectory)\**\*.sln' + includeNuGetOrg: false \ No newline at end of file