From 1d495d988d83ee0926fbfc21101b1a886c35d8a4 Mon Sep 17 00:00:00 2001 From: Shuai Yuan <128874481+shuaiyuanxx@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:19:41 +0800 Subject: [PATCH 01/16] enabled pipeline for updating WinAppSDK checking Signed-off-by: Shawn Yuan --- .pipelines/UpdateVersions.ps1 | 74 +++++ .pipelines/v2/ci.yml | 113 +++++++- .../v2/templates/job-build-project-simple.yml | 256 ++++++++++++++++++ PackLocation/readme.md | 1 + localpackages/readme.md | 1 + nuget.config | 27 +- 6 files changed, 449 insertions(+), 23 deletions(-) create mode 100644 .pipelines/UpdateVersions.ps1 create mode 100644 .pipelines/v2/templates/job-build-project-simple.yml create mode 100644 PackLocation/readme.md create mode 100644 localpackages/readme.md diff --git a/.pipelines/UpdateVersions.ps1 b/.pipelines/UpdateVersions.ps1 new file mode 100644 index 000000000000..4a6bc0764deb --- /dev/null +++ b/.pipelines/UpdateVersions.ps1 @@ -0,0 +1,74 @@ +# Execute nuget list and capture the output +$nugetOutput = nuget list Microsoft.WindowsAppSDK ` + -Source "https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json" ` + -AllVersions + +$filteredVersions = $nugetOutput | Where-Object { $_ -match "Microsoft.WindowsAppSDK 1\.6\." } +# Write-Host "Filtered versions: $filteredVersions" +$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 + } +} \ No newline at end of file diff --git a/.pipelines/v2/ci.yml b/.pipelines/v2/ci.yml index 0b8daa76d63f..74e395a6524a 100644 --- a/.pipelines/v2/ci.yml +++ b/.pipelines/v2/ci.yml @@ -23,29 +23,116 @@ pr: name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr) +resources: + repositories: + - repository: 1ESPipelineTemplates + type: git + name: 1ESPipelineTemplates/1ESPipelineTemplates + ref: refs/tags/release + +# Expose all of these parameters for user configuration. parameters: + - name: publishSymbolsToPublic + displayName: "Publish Symbols to **PUBLIC** (use only for Final Builds)" + type: boolean + default: false + + - name: versionNumber + displayName: "Version Number" + type: string + default: '0.0.1' + + - name: buildConfigurations + displayName: "Build Configurations" + type: object + default: + - Release + - name: buildPlatforms + displayName: "Build Platforms" 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 +# - task: PowerShell@2 +# displayName: UpdateVersions +# inputs: +# filePath: '.\.pipelines\UpdateVersions.ps1' +# - task: NuGetCommand@2 +# inputs: +# command: 'restore' +# restoreSolution: '**/*.sln' +# feedsToUse: 'config' +# nugetConfigPath: './nuget.config' +# includeNuGetOrg: false +# displayName: 'Restore NuGet packages' extends: - template: templates/pipeline-ci-build.yml + template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates parameters: - buildPlatforms: ${{ parameters.buildPlatforms }} - enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} - runTests: ${{ parameters.runTests }} - useVSPreview: ${{ parameters.useVSPreview }} + customBuildTags: + - 1ES.PT.ViaStartRight + pool: + name: SHINE-INT-L + ${{ if eq(parameters.useVSPreview, true) }}: + demands: ImageOverride -equals SHINE-VS17-Preview + ${{ else }}: + image: SHINE-VS17-Latest + os: windows + # sdl: + # tsa: + # enabled: true + # configFile: '$(Build.SourcesDirectory)\.pipelines\tsa.json' + + stages: + - stage: Build + displayName: Build + dependsOn: [] + jobs: + - template: .pipelines/v2/templates/job-build-project-simple.yml@self + parameters: + pool: + name: SHINE-INT-L + ${{ if eq(parameters.useVSPreview, true) }}: + demands: ImageOverride -equals SHINE-VS17-Preview + ${{ else }}: + image: SHINE-VS17-Latest + os: windows + variables: + IsPipeline: 1 # The installer uses this to detect whether it should pick up localizations + SkipCppCodeAnalysis: 1 # Skip the code analysis to speed up release CI. It runs on PR CI, anyway + # IsExperimentationLive: 1 # The build and installer use this to turn on experimentation + buildPlatforms: ${{ parameters.buildPlatforms }} + buildConfigurations: ${{ parameters.buildConfigurations }} + versionNumber: ${{ parameters.versionNumber }} + publishArtifacts: false # 1ES PT handles publication for us. + codeSign: false + runTests: false + # signingIdentity: + # serviceName: $(SigningServiceName) + # appId: $(SigningAppId) + # tenantId: $(SigningTenantId) + # akvName: $(SigningAKVName) + # authCertName: $(SigningAuthCertName) + # signCertName: $(SigningSignCertName) + # Have msbuild use the release nuget config profile + # additionalBuildOptions: /p:RestoreConfigFile="$(Build.SourcesDirectory)\.pipelines\release-nuget.config" + # beforeBuildSteps: + # # Sets versions for all PowerToy created DLLs + # - pwsh: |- + # .pipelines/versionSetting.ps1 -versionNumber '${{ parameters.versionNumber }}' -DevEnvironment '' + # displayName: Prepare versioning + + # # Prepare the localizations and telemetry config before the release build + # - template: .pipelines/v2/templates/steps-fetch-and-prepare-localizations.yml@self + + # - script: | + # call nuget.exe restore -configFile .pipelines/release-nuget.config -PackagesDirectory . .pipelines/packages.config || exit /b 1 + # move /Y "Microsoft.PowerToys.Telemetry.2.0.2\build\include\TraceLoggingDefines.h" "src\common\Telemetry\TraceLoggingDefines.h" || exit /b 1 + # move /Y "Microsoft.PowerToys.Telemetry.2.0.2\build\include\TelemetryBase.cs" "src\common\Telemetry\TelemetryBase.cs" || exit /b 1 + # displayName: Emplace telemetry files \ No newline at end of file diff --git a/.pipelines/v2/templates/job-build-project-simple.yml b/.pipelines/v2/templates/job-build-project-simple.yml new file mode 100644 index 000000000000..b45dacae80c1 --- /dev/null +++ b/.pipelines/v2/templates/job-build-project-simple.yml @@ -0,0 +1,256 @@ +parameters: + - name: additionalBuildOptions + type: string + default: '' + - name: buildConfigurations + type: object + default: + - Release + - name: buildPlatforms + type: object + default: + - x64 + - arm64 + - name: codeSign + type: boolean + default: false + - name: artifactStem + type: string + default: '' + - name: jobName + type: string + default: 'Build' + - name: condition + type: string + default: '' + - name: dependsOn + type: object + default: [] + - name: pool + type: object + default: [] + - name: beforeBuildSteps + type: stepList + default: [] + - name: variables + type: object + default: {} + - name: publishArtifacts + type: boolean + default: true + - name: signingIdentity + type: object + default: {} + - name: enablePackageCaching + type: boolean + default: false + - name: enableMsBuildCaching + type: boolean + default: false + - name: runTests + type: boolean + default: true + - name: useVSPreview + type: boolean + default: false + - name: versionNumber + type: string + default: '0.0.1' + - name: csProjectsToPublish + type: object + default: + - 'src/settings-ui/Settings.UI/PowerToys.Settings.csproj' + - 'src/modules/launcher/PowerLauncher/PowerLauncher.csproj' + - 'src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandler.csproj' + - 'src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandler.csproj' + - 'src/modules/previewpane/SvgPreviewHandler/SvgPreviewHandler.csproj' + - 'src/modules/previewpane/SvgThumbnailProvider/SvgThumbnailProvider.csproj' + - 'src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csproj' + +jobs: +- job: ${{ parameters.jobName }} + ${{ if ne(length(parameters.pool), 0) }}: + pool: ${{ parameters.pool }} + dependsOn: ${{ parameters.dependsOn }} + condition: ${{ parameters.condition }} + strategy: + matrix: + ${{ each config in parameters.buildConfigurations }}: + ${{ each platform in parameters.buildPlatforms }}: + ${{ config }}_${{ platform }}: + BuildConfiguration: ${{ config }} + BuildPlatform: ${{ platform }} + ${{ if eq(platform, 'x86') }}: + OutputBuildPlatform: Win32 + ${{ elseif eq(platform, 'Any CPU') }}: + OutputBuildPlatform: AnyCPU + ${{ else }}: + OutputBuildPlatform: ${{ platform }} + variables: + # Azure DevOps abhors a vacuum + # If these are blank, expansion will fail later on... which will result in direct substitution of the variable *names* + # later on. We'll just... set them to a single space and if we need to, check IsNullOrWhiteSpace. + # Yup. + MSBuildCacheParameters: ' ' + JobOutputDirectory: $(Build.ArtifactStagingDirectory) + LogOutputDirectory: $(Build.ArtifactStagingDirectory)\logs + JobOutputArtifactName: build-$(BuildPlatform)-$(BuildConfiguration)${{ parameters.artifactStem }} + NUGET_RESTORE_MSBUILD_ARGS: /p:Platform=$(BuildPlatform) # Required for nuget to work due to self contained + NODE_OPTIONS: --max_old_space_size=16384 + ${{ if eq(parameters.runTests, true) }}: + MSBuildMainBuildTargets: Build;Test + ${{ else }}: + MSBuildMainBuildTargets: Build + ${{ insert }}: ${{ parameters.variables }} + displayName: Build + timeoutInMinutes: 240 + cancelTimeoutInMinutes: 1 + templateContext: # Required when this template is hosted in 1ES PT + outputs: + - output: pipelineArtifact + artifactName: $(JobOutputArtifactName) + targetPath: $(Build.ArtifactStagingDirectory) + steps: + - checkout: self + clean: true + submodules: true + persistCredentials: True + fetchTags: false + fetchDepth: 1 + + - ${{ if eq(parameters.enableMsBuildCaching, true) }}: + - pwsh: |- + $MSBuildCacheParameters = "" + $MSBuildCacheParameters += " -graph" + $MSBuildCacheParameters += " -reportfileaccesses" + $MSBuildCacheParameters += " -p:MSBuildCacheEnabled=true" + $MSBuildCacheParameters += " -p:MSBuildCacheLogDirectory=$(LogOutputDirectory)\MSBuildCacheLogs" + Write-Host "MSBuildCacheParameters: $MSBuildCacheParameters" + Write-Host "##vso[task.setvariable variable=MSBuildCacheParameters]$MSBuildCacheParameters" + displayName: Prepare MSBuildCache variables + + - template: steps-ensure-dotnet-version.yml + parameters: + sdk: true + version: '6.0' + + - template: steps-ensure-dotnet-version.yml + parameters: + sdk: true + version: '9.0' + + - ${{ if eq(parameters.runTests, true) }}: + - task: VisualStudioTestPlatformInstaller@1 + displayName: Ensure VSTest Platform + + # - pwsh: |- + # & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\PowerToys.sln' + # & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\BugReportTool\BugReportTool.sln' + # & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\WebcamReportTool\WebcamReportTool.sln' + # & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\StylesReportTool\StylesReportTool.sln' + # & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\installer\PowerToysSetup.sln' + # displayName: Verify ARM64 configurations + + # - ${{ if eq(parameters.enablePackageCaching, true) }}: + # - task: Cache@2 + # displayName: 'Cache nuget packages (PackageReference)' + # inputs: + # key: '"PackageReference" | "$(Agent.OS)" | Directory.Packages.props' + # restoreKeys: | + # "PackageReference" | "$(Agent.OS)" + # "PackageReference" + # path: $(NUGET_PACKAGES) + + # - task: Cache@2 + # displayName: 'Cache nuget packages (packages.config)' + # inputs: + # key: '"packages.config" | "$(Agent.OS)" | **/packages.config' + # restoreKeys: | + # "packages.config" | "$(Agent.OS)" + # "packages.config" + # path: packages + + - task: NuGetAuthenticate@1 + + - task: PowerShell@2 + displayName: Update WinAppSDK Versions + inputs: + filePath: '$(build.sourcesdirectory)\.pipelines\UpdateVersions.ps1' + + - 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/1.6-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" + + # In the Microsoft Azure DevOps tenant, NuGetCommand is ambiguous. + # This should be `task: NuGetCommand@2` + - task: NuGetCommand@2 + displayName: Restore NuGet packages + inputs: + command: 'restore' + feedsToUse: 'config' + nugetConfigPath: '$(build.sourcesdirectory)\nuget.config' + restoreSolution: '$(build.sourcesdirectory)\**\*.sln' + includeNuGetOrg: false + + - pwsh: |- + & "$(build.sourcesdirectory)\.pipelines\verifyAndSetLatestVCToolsVersion.ps1" + displayName: Work around DD-1541167 (VCToolsVersion) + ${{ if eq(parameters.useVSPreview, true) }}: + env: + VCWhereExtraVersionTarget: '-prerelease' + + - pwsh: |- + & "$(build.sourcesdirectory)\.pipelines\installWiX.ps1" + displayName: Download and install WiX 3.14 development build + + - ${{ parameters.beforeBuildSteps }} + + - task: VSBuild@1 + ${{ if eq(parameters.runTests, true) }}: + displayName: Build and Test PowerToys main project + ${{ else }}: + displayName: Build PowerToys main project + inputs: + solution: 'PowerToys.sln' + vsVersion: 17.0 + msbuildArgs: >- + -restore -graph + /p:RestorePackagesConfig=true + /p:CIBuild=true + /bl:$(LogOutputDirectory)\build-0-main.binlog + ${{ parameters.additionalBuildOptions }} + $(MSBuildCacheParameters) + /t:$(MSBuildMainBuildTargets) + /p:RestoreAdditionalProjectSources="$(Build.SourcesDirectory)\localpackages\NugetPackages" + platform: $(BuildPlatform) + configuration: $(BuildConfiguration) + msbuildArchitecture: x64 + maximumCpuCount: true + ${{ if eq(parameters.enableMsBuildCaching, true) }}: + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + diff --git a/PackLocation/readme.md b/PackLocation/readme.md new file mode 100644 index 000000000000..e8407a0cac4e --- /dev/null +++ b/PackLocation/readme.md @@ -0,0 +1 @@ +Local source for packages. Microsoft.WindowsAppSDK.*.nupkg get placed here when building locally. \ No newline at end of file diff --git a/localpackages/readme.md b/localpackages/readme.md new file mode 100644 index 000000000000..bb3aaa6517f0 --- /dev/null +++ b/localpackages/readme.md @@ -0,0 +1 @@ +Local source for packages. Places nupkg files in this directory to test them out before uploading. \ No newline at end of file diff --git a/nuget.config b/nuget.config index e6a17ffdfed7..2dc48a217e50 100644 --- a/nuget.config +++ b/nuget.config @@ -1,12 +1,19 @@ - + - - - - - - - - - + + + + + + + + + + + + + + + + From ed38a2a17450727e504f6563fed82a3bbbc8eae1 Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Wed, 4 Dec 2024 09:35:04 +0800 Subject: [PATCH 02/16] add test Signed-off-by: Shawn Yuan --- .../v2/templates/job-build-project-simple.yml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.pipelines/v2/templates/job-build-project-simple.yml b/.pipelines/v2/templates/job-build-project-simple.yml index b45dacae80c1..7d275abb0bed 100644 --- a/.pipelines/v2/templates/job-build-project-simple.yml +++ b/.pipelines/v2/templates/job-build-project-simple.yml @@ -254,3 +254,26 @@ jobs: env: SYSTEM_ACCESSTOKEN: $(System.AccessToken) + - task: PublishTestResults@2 + condition: ne(variables['BuildPlatform'],'arm64') + displayName: 'Publish Test Results' + inputs: + testResultsFormat: VSTest + testResultsFiles: '**/*.trx' + + # Native dlls + - task: VSTest@2 + condition: ne(variables['BuildPlatform'],'arm64') # No arm64 agents to run the tests. + displayName: 'Native Tests' + inputs: + platform: '$(BuildPlatform)' + configuration: '$(BuildConfiguration)' + testSelector: 'testAssemblies' + testAssemblyVer2: | + **\KeyboardManagerEngineTest.dll + **\KeyboardManagerEditorTest.dll + **\UnitTests-CommonLib.dll + **\PowerRenameUnitTests.dll + **\UnitTests-FancyZones.dll + !**\obj\** + From caadfe26492117d3b3c3523f015278cee2a84541 Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Wed, 4 Dec 2024 13:54:29 +0800 Subject: [PATCH 03/16] code clean Signed-off-by: Shawn Yuan --- .pipelines/v2/ci.yml | 30 +++---------- ...-build-project-using-latest-winappsdk.yml} | 45 ++++++++++--------- 2 files changed, 29 insertions(+), 46 deletions(-) rename .pipelines/v2/templates/{job-build-project-simple.yml => job-build-project-using-latest-winappsdk.yml} (91%) diff --git a/.pipelines/v2/ci.yml b/.pipelines/v2/ci.yml index 74e395a6524a..39d0eedd6c75 100644 --- a/.pipelines/v2/ci.yml +++ b/.pipelines/v2/ci.yml @@ -30,13 +30,7 @@ resources: name: 1ESPipelineTemplates/1ESPipelineTemplates ref: refs/tags/release -# Expose all of these parameters for user configuration. parameters: - - name: publishSymbolsToPublic - displayName: "Publish Symbols to **PUBLIC** (use only for Final Builds)" - type: boolean - default: false - - name: versionNumber displayName: "Version Number" type: string @@ -59,19 +53,7 @@ parameters: type: boolean displayName: "Build Using Visual Studio Preview" default: false -# - task: PowerShell@2 -# displayName: UpdateVersions -# inputs: -# filePath: '.\.pipelines\UpdateVersions.ps1' -# - task: NuGetCommand@2 -# inputs: -# command: 'restore' -# restoreSolution: '**/*.sln' -# feedsToUse: 'config' -# nugetConfigPath: './nuget.config' -# includeNuGetOrg: false -# displayName: 'Restore NuGet packages' extends: template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates parameters: @@ -84,17 +66,17 @@ extends: ${{ else }}: image: SHINE-VS17-Latest os: windows - # sdl: - # tsa: - # enabled: true - # configFile: '$(Build.SourcesDirectory)\.pipelines\tsa.json' + sdl: + tsa: + enabled: true + configFile: '$(Build.SourcesDirectory)\.pipelines\tsa.json' stages: - stage: Build displayName: Build dependsOn: [] jobs: - - template: .pipelines/v2/templates/job-build-project-simple.yml@self + - template: .pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml@self parameters: pool: name: SHINE-INT-L @@ -112,7 +94,7 @@ extends: versionNumber: ${{ parameters.versionNumber }} publishArtifacts: false # 1ES PT handles publication for us. codeSign: false - runTests: false + runTests: true # signingIdentity: # serviceName: $(SigningServiceName) # appId: $(SigningAppId) diff --git a/.pipelines/v2/templates/job-build-project-simple.yml b/.pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml similarity index 91% rename from .pipelines/v2/templates/job-build-project-simple.yml rename to .pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml index 7d275abb0bed..a47c37812275 100644 --- a/.pipelines/v2/templates/job-build-project-simple.yml +++ b/.pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml @@ -254,26 +254,27 @@ jobs: env: SYSTEM_ACCESSTOKEN: $(System.AccessToken) - - task: PublishTestResults@2 - condition: ne(variables['BuildPlatform'],'arm64') - displayName: 'Publish Test Results' - inputs: - testResultsFormat: VSTest - testResultsFiles: '**/*.trx' - - # Native dlls - - task: VSTest@2 - condition: ne(variables['BuildPlatform'],'arm64') # No arm64 agents to run the tests. - displayName: 'Native Tests' - inputs: - platform: '$(BuildPlatform)' - configuration: '$(BuildConfiguration)' - testSelector: 'testAssemblies' - testAssemblyVer2: | - **\KeyboardManagerEngineTest.dll - **\KeyboardManagerEditorTest.dll - **\UnitTests-CommonLib.dll - **\PowerRenameUnitTests.dll - **\UnitTests-FancyZones.dll - !**\obj\** + - ${{ if eq(parameters.runTests, true) }}: + - task: PublishTestResults@2 + condition: ne(variables['BuildPlatform'],'arm64') + displayName: 'Publish Test Results' + inputs: + testResultsFormat: VSTest + testResultsFiles: '**/*.trx' + + # Native dlls + - task: VSTest@2 + condition: ne(variables['BuildPlatform'],'arm64') # No arm64 agents to run the tests. + displayName: 'Native Tests' + inputs: + platform: '$(BuildPlatform)' + configuration: '$(BuildConfiguration)' + testSelector: 'testAssemblies' + testAssemblyVer2: | + **\KeyboardManagerEngineTest.dll + **\KeyboardManagerEditorTest.dll + **\UnitTests-CommonLib.dll + **\PowerRenameUnitTests.dll + **\UnitTests-FancyZones.dll + !**\obj\** From 2fd66fa30d6286bb3054059b996bf513863191ae Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Wed, 4 Dec 2024 14:10:43 +0800 Subject: [PATCH 04/16] code clean Signed-off-by: Shawn Yuan --- .pipelines/v2/ci.yml | 22 +------------------ ...b-build-project-using-latest-winappsdk.yml | 3 --- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/.pipelines/v2/ci.yml b/.pipelines/v2/ci.yml index 39d0eedd6c75..d05410eff05a 100644 --- a/.pipelines/v2/ci.yml +++ b/.pipelines/v2/ci.yml @@ -31,11 +31,6 @@ resources: ref: refs/tags/release parameters: - - name: versionNumber - displayName: "Version Number" - type: string - default: '0.0.1' - - name: buildConfigurations displayName: "Build Configurations" type: object @@ -91,7 +86,6 @@ extends: # IsExperimentationLive: 1 # The build and installer use this to turn on experimentation buildPlatforms: ${{ parameters.buildPlatforms }} buildConfigurations: ${{ parameters.buildConfigurations }} - versionNumber: ${{ parameters.versionNumber }} publishArtifacts: false # 1ES PT handles publication for us. codeSign: false runTests: true @@ -103,18 +97,4 @@ extends: # authCertName: $(SigningAuthCertName) # signCertName: $(SigningSignCertName) # Have msbuild use the release nuget config profile - # additionalBuildOptions: /p:RestoreConfigFile="$(Build.SourcesDirectory)\.pipelines\release-nuget.config" - # beforeBuildSteps: - # # Sets versions for all PowerToy created DLLs - # - pwsh: |- - # .pipelines/versionSetting.ps1 -versionNumber '${{ parameters.versionNumber }}' -DevEnvironment '' - # displayName: Prepare versioning - - # # Prepare the localizations and telemetry config before the release build - # - template: .pipelines/v2/templates/steps-fetch-and-prepare-localizations.yml@self - - # - script: | - # call nuget.exe restore -configFile .pipelines/release-nuget.config -PackagesDirectory . .pipelines/packages.config || exit /b 1 - # move /Y "Microsoft.PowerToys.Telemetry.2.0.2\build\include\TraceLoggingDefines.h" "src\common\Telemetry\TraceLoggingDefines.h" || exit /b 1 - # move /Y "Microsoft.PowerToys.Telemetry.2.0.2\build\include\TelemetryBase.cs" "src\common\Telemetry\TelemetryBase.cs" || exit /b 1 - # displayName: Emplace telemetry files \ No newline at end of file + # additionalBuildOptions: /p:RestoreConfigFile="$(Build.SourcesDirectory)\.pipelines\release-nuget.config" \ No newline at end of file diff --git a/.pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml b/.pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml index a47c37812275..2ffb7fdc41b9 100644 --- a/.pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml +++ b/.pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml @@ -53,9 +53,6 @@ parameters: - name: useVSPreview type: boolean default: false - - name: versionNumber - type: string - default: '0.0.1' - name: csProjectsToPublish type: object default: From 448ea2914db80699162672f5e82777369638697a Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Wed, 4 Dec 2024 16:03:57 +0800 Subject: [PATCH 05/16] modify and using the existing pipelines Signed-off-by: Shawn Yuan --- .pipelines/v2/ci.yml | 79 ++++--------------- .pipelines/v2/templates/job-build-project.yml | 60 +++++++++++--- .pipelines/v2/templates/pipeline-ci-build.yml | 4 + ...eps-update-winappsdk-and-restore-nuget.yml | 45 +++++++++++ nuget.config | 5 -- 5 files changed, 115 insertions(+), 78 deletions(-) create mode 100644 .pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml diff --git a/.pipelines/v2/ci.yml b/.pipelines/v2/ci.yml index d05410eff05a..b124a437fb81 100644 --- a/.pipelines/v2/ci.yml +++ b/.pipelines/v2/ci.yml @@ -23,78 +23,33 @@ pr: name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr) -resources: - repositories: - - repository: 1ESPipelineTemplates - type: git - name: 1ESPipelineTemplates/1ESPipelineTemplates - ref: refs/tags/release - parameters: - - name: buildConfigurations - displayName: "Build Configurations" - type: object - default: - - Release - - name: buildPlatforms - displayName: "Build Platforms" 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: false extends: - template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates + template: templates/pipeline-ci-build.yml parameters: - customBuildTags: - - 1ES.PT.ViaStartRight - pool: - name: SHINE-INT-L - ${{ if eq(parameters.useVSPreview, true) }}: - demands: ImageOverride -equals SHINE-VS17-Preview - ${{ else }}: - image: SHINE-VS17-Latest - os: windows - sdl: - tsa: - enabled: true - configFile: '$(Build.SourcesDirectory)\.pipelines\tsa.json' - - stages: - - stage: Build - displayName: Build - dependsOn: [] - jobs: - - template: .pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml@self - parameters: - pool: - name: SHINE-INT-L - ${{ if eq(parameters.useVSPreview, true) }}: - demands: ImageOverride -equals SHINE-VS17-Preview - ${{ else }}: - image: SHINE-VS17-Latest - os: windows - variables: - IsPipeline: 1 # The installer uses this to detect whether it should pick up localizations - SkipCppCodeAnalysis: 1 # Skip the code analysis to speed up release CI. It runs on PR CI, anyway - # IsExperimentationLive: 1 # The build and installer use this to turn on experimentation - buildPlatforms: ${{ parameters.buildPlatforms }} - buildConfigurations: ${{ parameters.buildConfigurations }} - publishArtifacts: false # 1ES PT handles publication for us. - codeSign: false - runTests: true - # signingIdentity: - # serviceName: $(SigningServiceName) - # appId: $(SigningAppId) - # tenantId: $(SigningTenantId) - # akvName: $(SigningAKVName) - # authCertName: $(SigningAuthCertName) - # signCertName: $(SigningSignCertName) - # Have msbuild use the release nuget config profile - # additionalBuildOptions: /p:RestoreConfigFile="$(Build.SourcesDirectory)\.pipelines\release-nuget.config" \ No newline at end of file + buildPlatforms: ${{ parameters.buildPlatforms }} + enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} + runTests: ${{ parameters.runTests }} + useVSPreview: ${{ parameters.useVSPreview }} + useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }} diff --git a/.pipelines/v2/templates/job-build-project.yml b/.pipelines/v2/templates/job-build-project.yml index 1933b74e8de9..034efdba916d 100644 --- a/.pipelines/v2/templates/job-build-project.yml +++ b/.pipelines/v2/templates/job-build-project.yml @@ -56,6 +56,9 @@ parameters: - name: versionNumber type: string default: '0.0.1' + - name: useLatestWinAppSDK + type: boolean + default: false - name: csProjectsToPublish type: object default: @@ -102,6 +105,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 @@ -177,8 +184,12 @@ 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 + + - ${{ if eq(parameters.useLatestWinAppSDK, false)}}: + - template: .\steps-restore-nuget.yml - pwsh: |- & "$(build.sourcesdirectory)\.pipelines\verifyAndSetLatestVCToolsVersion.ps1" @@ -209,6 +220,7 @@ jobs: ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) /t:$(MSBuildMainBuildTargets) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -234,9 +246,16 @@ jobs: 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 + msbuildArgs: >- + /p:CIBuild=true;NoBuild=true -t:pack + /bl:$(LogOutputDirectory)\build-hosts.binlog + /p:NoWarn=NU5104 + $(RestoreAdditionalProjectSourcesArg) ${{ 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 + $(RestoreAdditionalProjectSourcesArg) configuration: $(BuildConfiguration) msbuildArchitecture: x64 maximumCpuCount: true @@ -250,9 +269,16 @@ jobs: 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 + msbuildArgs: >- + /p:CIBuild=true;NoBuild=true -t:pack + /bl:$(LogOutputDirectory)\build-env-var-editor.binlog + /p:NoWarn=NU5104 + $(RestoreAdditionalProjectSourcesArg) ${{ 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 + $(RestoreAdditionalProjectSourcesArg) configuration: $(BuildConfiguration) msbuildArchitecture: x64 maximumCpuCount: true @@ -266,9 +292,16 @@ jobs: 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 + msbuildArgs: >- + /p:CIBuild=true;NoBuild=true -t:pack + /bl:$(LogOutputDirectory)\build-registry-preview.binlog + /p:NoWarn=NU5104 + $(RestoreAdditionalProjectSourcesArg) ${{ 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 + $(RestoreAdditionalProjectSourcesArg) configuration: $(BuildConfiguration) msbuildArchitecture: x64 maximumCpuCount: true @@ -323,6 +356,7 @@ jobs: /bl:$(LogOutputDirectory)\build-bug-report.binlog ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -343,6 +377,7 @@ jobs: /bl:$(LogOutputDirectory)\build-webcam-report.binlog ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -363,6 +398,7 @@ jobs: /bl:$(LogOutputDirectory)\build-styles-report.binlog ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -385,6 +421,7 @@ jobs: /p:PowerToysRoot=$(Build.SourcesDirectory) /p:PublishProfile=InstallationPublishProfile.pubxml /bl:$(LogOutputDirectory)\publish-${{ join('_',split(project, '/')) }}.binlog + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -414,9 +451,10 @@ 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 + - ${{ 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 71ebd6a33b47..0c184e486cb6 100644 --- a/.pipelines/v2/templates/pipeline-ci-build.yml +++ b/.pipelines/v2/templates/pipeline-ci-build.yml @@ -22,6 +22,9 @@ parameters: - name: useVSPreview type: boolean default: false + - name: useLatestWinAppSDK + type: boolean + default: false stages: # Allow manual builds to skip pre-check @@ -55,6 +58,7 @@ stages: enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} runTests: ${{ parameters.runTests }} useVSPreview: ${{ parameters.useVSPreview }} + useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }} - ${{ 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 000000000000..944dab83c7cc --- /dev/null +++ b/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml @@ -0,0 +1,45 @@ +steps: +- task: NuGetAuthenticate@1 + displayName: 'NuGet Authenticate' + +- task: PowerShell@2 + displayName: Update WinAppSDK Versions + inputs: + filePath: '$(build.sourcesdirectory)\.pipelines\UpdateVersions.ps1' + +- 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/1.6-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 diff --git a/nuget.config b/nuget.config index 2dc48a217e50..9ce60e0a5809 100644 --- a/nuget.config +++ b/nuget.config @@ -1,10 +1,5 @@ - - - - - From de258b83ca1b3e4a8bec60542dd3972b7b06e013 Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Thu, 5 Dec 2024 09:17:36 +0800 Subject: [PATCH 06/16] update Signed-off-by: Shawn Yuan --- PackLocation/readme.md | 1 - localpackages/readme.md | 1 - nuget.config | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 PackLocation/readme.md delete mode 100644 localpackages/readme.md diff --git a/PackLocation/readme.md b/PackLocation/readme.md deleted file mode 100644 index e8407a0cac4e..000000000000 --- a/PackLocation/readme.md +++ /dev/null @@ -1 +0,0 @@ -Local source for packages. Microsoft.WindowsAppSDK.*.nupkg get placed here when building locally. \ No newline at end of file diff --git a/localpackages/readme.md b/localpackages/readme.md deleted file mode 100644 index bb3aaa6517f0..000000000000 --- a/localpackages/readme.md +++ /dev/null @@ -1 +0,0 @@ -Local source for packages. Places nupkg files in this directory to test them out before uploading. \ No newline at end of file diff --git a/nuget.config b/nuget.config index 9ce60e0a5809..5dd51f78a027 100644 --- a/nuget.config +++ b/nuget.config @@ -6,7 +6,7 @@ - + From 90125a356a3225af72081b92e92e407abd33ba87 Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Thu, 5 Dec 2024 10:23:11 +0800 Subject: [PATCH 07/16] add yml file --- .../v2/ci-using-the-latest-winappsdk.yml | 55 ++++ ...b-build-project-using-latest-winappsdk.yml | 277 ------------------ 2 files changed, 55 insertions(+), 277 deletions(-) create mode 100644 .pipelines/v2/ci-using-the-latest-winappsdk.yml delete mode 100644 .pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml 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 000000000000..4db697d19ab2 --- /dev/null +++ b/.pipelines/v2/ci-using-the-latest-winappsdk.yml @@ -0,0 +1,55 @@ +trigger: + batch: true + branches: + include: + - main + - stable +# paths: +# exclude: +# - doc/* +# - temp/* +# - tools/* +# - '**.md' + +pr: + branches: + include: + - main + - stable +# paths: +# exclude: +# - '**.md' +# - doc + +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 + +extends: + template: templates/pipeline-ci-build.yml + parameters: + buildPlatforms: ${{ parameters.buildPlatforms }} + enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} + runTests: ${{ parameters.runTests }} + useVSPreview: ${{ parameters.useVSPreview }} + useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }} diff --git a/.pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml b/.pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml deleted file mode 100644 index 2ffb7fdc41b9..000000000000 --- a/.pipelines/v2/templates/job-build-project-using-latest-winappsdk.yml +++ /dev/null @@ -1,277 +0,0 @@ -parameters: - - name: additionalBuildOptions - type: string - default: '' - - name: buildConfigurations - type: object - default: - - Release - - name: buildPlatforms - type: object - default: - - x64 - - arm64 - - name: codeSign - type: boolean - default: false - - name: artifactStem - type: string - default: '' - - name: jobName - type: string - default: 'Build' - - name: condition - type: string - default: '' - - name: dependsOn - type: object - default: [] - - name: pool - type: object - default: [] - - name: beforeBuildSteps - type: stepList - default: [] - - name: variables - type: object - default: {} - - name: publishArtifacts - type: boolean - default: true - - name: signingIdentity - type: object - default: {} - - name: enablePackageCaching - type: boolean - default: false - - name: enableMsBuildCaching - type: boolean - default: false - - name: runTests - type: boolean - default: true - - name: useVSPreview - type: boolean - default: false - - name: csProjectsToPublish - type: object - default: - - 'src/settings-ui/Settings.UI/PowerToys.Settings.csproj' - - 'src/modules/launcher/PowerLauncher/PowerLauncher.csproj' - - 'src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandler.csproj' - - 'src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandler.csproj' - - 'src/modules/previewpane/SvgPreviewHandler/SvgPreviewHandler.csproj' - - 'src/modules/previewpane/SvgThumbnailProvider/SvgThumbnailProvider.csproj' - - 'src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csproj' - -jobs: -- job: ${{ parameters.jobName }} - ${{ if ne(length(parameters.pool), 0) }}: - pool: ${{ parameters.pool }} - dependsOn: ${{ parameters.dependsOn }} - condition: ${{ parameters.condition }} - strategy: - matrix: - ${{ each config in parameters.buildConfigurations }}: - ${{ each platform in parameters.buildPlatforms }}: - ${{ config }}_${{ platform }}: - BuildConfiguration: ${{ config }} - BuildPlatform: ${{ platform }} - ${{ if eq(platform, 'x86') }}: - OutputBuildPlatform: Win32 - ${{ elseif eq(platform, 'Any CPU') }}: - OutputBuildPlatform: AnyCPU - ${{ else }}: - OutputBuildPlatform: ${{ platform }} - variables: - # Azure DevOps abhors a vacuum - # If these are blank, expansion will fail later on... which will result in direct substitution of the variable *names* - # later on. We'll just... set them to a single space and if we need to, check IsNullOrWhiteSpace. - # Yup. - MSBuildCacheParameters: ' ' - JobOutputDirectory: $(Build.ArtifactStagingDirectory) - LogOutputDirectory: $(Build.ArtifactStagingDirectory)\logs - JobOutputArtifactName: build-$(BuildPlatform)-$(BuildConfiguration)${{ parameters.artifactStem }} - NUGET_RESTORE_MSBUILD_ARGS: /p:Platform=$(BuildPlatform) # Required for nuget to work due to self contained - NODE_OPTIONS: --max_old_space_size=16384 - ${{ if eq(parameters.runTests, true) }}: - MSBuildMainBuildTargets: Build;Test - ${{ else }}: - MSBuildMainBuildTargets: Build - ${{ insert }}: ${{ parameters.variables }} - displayName: Build - timeoutInMinutes: 240 - cancelTimeoutInMinutes: 1 - templateContext: # Required when this template is hosted in 1ES PT - outputs: - - output: pipelineArtifact - artifactName: $(JobOutputArtifactName) - targetPath: $(Build.ArtifactStagingDirectory) - steps: - - checkout: self - clean: true - submodules: true - persistCredentials: True - fetchTags: false - fetchDepth: 1 - - - ${{ if eq(parameters.enableMsBuildCaching, true) }}: - - pwsh: |- - $MSBuildCacheParameters = "" - $MSBuildCacheParameters += " -graph" - $MSBuildCacheParameters += " -reportfileaccesses" - $MSBuildCacheParameters += " -p:MSBuildCacheEnabled=true" - $MSBuildCacheParameters += " -p:MSBuildCacheLogDirectory=$(LogOutputDirectory)\MSBuildCacheLogs" - Write-Host "MSBuildCacheParameters: $MSBuildCacheParameters" - Write-Host "##vso[task.setvariable variable=MSBuildCacheParameters]$MSBuildCacheParameters" - displayName: Prepare MSBuildCache variables - - - template: steps-ensure-dotnet-version.yml - parameters: - sdk: true - version: '6.0' - - - template: steps-ensure-dotnet-version.yml - parameters: - sdk: true - version: '9.0' - - - ${{ if eq(parameters.runTests, true) }}: - - task: VisualStudioTestPlatformInstaller@1 - displayName: Ensure VSTest Platform - - # - pwsh: |- - # & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\PowerToys.sln' - # & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\BugReportTool\BugReportTool.sln' - # & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\WebcamReportTool\WebcamReportTool.sln' - # & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\StylesReportTool\StylesReportTool.sln' - # & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\installer\PowerToysSetup.sln' - # displayName: Verify ARM64 configurations - - # - ${{ if eq(parameters.enablePackageCaching, true) }}: - # - task: Cache@2 - # displayName: 'Cache nuget packages (PackageReference)' - # inputs: - # key: '"PackageReference" | "$(Agent.OS)" | Directory.Packages.props' - # restoreKeys: | - # "PackageReference" | "$(Agent.OS)" - # "PackageReference" - # path: $(NUGET_PACKAGES) - - # - task: Cache@2 - # displayName: 'Cache nuget packages (packages.config)' - # inputs: - # key: '"packages.config" | "$(Agent.OS)" | **/packages.config' - # restoreKeys: | - # "packages.config" | "$(Agent.OS)" - # "packages.config" - # path: packages - - - task: NuGetAuthenticate@1 - - - task: PowerShell@2 - displayName: Update WinAppSDK Versions - inputs: - filePath: '$(build.sourcesdirectory)\.pipelines\UpdateVersions.ps1' - - - 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/1.6-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" - - # In the Microsoft Azure DevOps tenant, NuGetCommand is ambiguous. - # This should be `task: NuGetCommand@2` - - task: NuGetCommand@2 - displayName: Restore NuGet packages - inputs: - command: 'restore' - feedsToUse: 'config' - nugetConfigPath: '$(build.sourcesdirectory)\nuget.config' - restoreSolution: '$(build.sourcesdirectory)\**\*.sln' - includeNuGetOrg: false - - - pwsh: |- - & "$(build.sourcesdirectory)\.pipelines\verifyAndSetLatestVCToolsVersion.ps1" - displayName: Work around DD-1541167 (VCToolsVersion) - ${{ if eq(parameters.useVSPreview, true) }}: - env: - VCWhereExtraVersionTarget: '-prerelease' - - - pwsh: |- - & "$(build.sourcesdirectory)\.pipelines\installWiX.ps1" - displayName: Download and install WiX 3.14 development build - - - ${{ parameters.beforeBuildSteps }} - - - task: VSBuild@1 - ${{ if eq(parameters.runTests, true) }}: - displayName: Build and Test PowerToys main project - ${{ else }}: - displayName: Build PowerToys main project - inputs: - solution: 'PowerToys.sln' - vsVersion: 17.0 - msbuildArgs: >- - -restore -graph - /p:RestorePackagesConfig=true - /p:CIBuild=true - /bl:$(LogOutputDirectory)\build-0-main.binlog - ${{ parameters.additionalBuildOptions }} - $(MSBuildCacheParameters) - /t:$(MSBuildMainBuildTargets) - /p:RestoreAdditionalProjectSources="$(Build.SourcesDirectory)\localpackages\NugetPackages" - platform: $(BuildPlatform) - configuration: $(BuildConfiguration) - msbuildArchitecture: x64 - maximumCpuCount: true - ${{ if eq(parameters.enableMsBuildCaching, true) }}: - env: - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - - - ${{ if eq(parameters.runTests, true) }}: - - task: PublishTestResults@2 - condition: ne(variables['BuildPlatform'],'arm64') - displayName: 'Publish Test Results' - inputs: - testResultsFormat: VSTest - testResultsFiles: '**/*.trx' - - # Native dlls - - task: VSTest@2 - condition: ne(variables['BuildPlatform'],'arm64') # No arm64 agents to run the tests. - displayName: 'Native Tests' - inputs: - platform: '$(BuildPlatform)' - configuration: '$(BuildConfiguration)' - testSelector: 'testAssemblies' - testAssemblyVer2: | - **\KeyboardManagerEngineTest.dll - **\KeyboardManagerEditorTest.dll - **\UnitTests-CommonLib.dll - **\PowerRenameUnitTests.dll - **\UnitTests-FancyZones.dll - !**\obj\** - From 6d8129fedaf142157b54d3a609beae9275357555 Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Thu, 5 Dec 2024 11:46:02 +0800 Subject: [PATCH 08/16] change nuget.config --- nuget.config | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nuget.config b/nuget.config index 5dd51f78a027..d79c6352dc45 100644 --- a/nuget.config +++ b/nuget.config @@ -6,9 +6,5 @@ - - - - From 58f2f9a2d48ecdbd849215dd6fb71acd6567ef97 Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Thu, 5 Dec 2024 12:28:45 +0800 Subject: [PATCH 09/16] update nuget config --- .pipelines/UpdateVersions.ps1 | 25 ++++++++++++++++++++++++- nuget.config | 20 +++++++++++--------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/.pipelines/UpdateVersions.ps1 b/.pipelines/UpdateVersions.ps1 index 4a6bc0764deb..473af6775b67 100644 --- a/.pipelines/UpdateVersions.ps1 +++ b/.pipelines/UpdateVersions.ps1 @@ -71,4 +71,27 @@ Get-ChildItem -Recurse *.csproj | ForEach-Object { Set-Content -Path $_.FullName -Value $content Write-Host "Modified " $_.FullName } -} \ No newline at end of file +} + +# Load the nuget.config file +Write-Host "Updating nuget.config file" +$filePath = "nuget.config" +[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) diff --git a/nuget.config b/nuget.config index d79c6352dc45..f6b87352567d 100644 --- a/nuget.config +++ b/nuget.config @@ -1,10 +1,12 @@ - + - - - - - - - - + + + + + + + + + + \ No newline at end of file From cdc9fd9c0f87537016cb9a21e658470dd5d3c7d7 Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Thu, 5 Dec 2024 13:16:21 +0800 Subject: [PATCH 10/16] code clean --- nuget.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuget.config b/nuget.config index f6b87352567d..e6a17ffdfed7 100644 --- a/nuget.config +++ b/nuget.config @@ -9,4 +9,4 @@ - \ No newline at end of file + From b2a1c0e55ff0ef62e94ac2e330075ca3362d4d4c Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Thu, 5 Dec 2024 14:41:27 +0800 Subject: [PATCH 11/16] restore ci.yaml --- .pipelines/v2/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.pipelines/v2/ci.yml b/.pipelines/v2/ci.yml index b124a437fb81..0b8daa76d63f 100644 --- a/.pipelines/v2/ci.yml +++ b/.pipelines/v2/ci.yml @@ -41,9 +41,6 @@ parameters: type: boolean displayName: "Build Using Visual Studio Preview" default: false - - name: useLatestWinAppSDK - type: boolean - default: false extends: template: templates/pipeline-ci-build.yml @@ -52,4 +49,3 @@ extends: enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} runTests: ${{ parameters.runTests }} useVSPreview: ${{ parameters.useVSPreview }} - useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }} From 98086e9a62f4008fa872b89723f6ae5cbd0a7ec0 Mon Sep 17 00:00:00 2001 From: Clint Rutkas Date: Thu, 5 Dec 2024 08:12:48 -0800 Subject: [PATCH 12/16] Update expect.txt --- .github/actions/spell-check/expect.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index de32d2a32403..97d7044479d4 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -1917,3 +1917,5 @@ zonable zoneset Zoneszonabletester zzz +localpackage +winappsdk From e65b356b77f06c286a6c9f56b29b70f434ee7ffd Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Mon, 9 Dec 2024 11:15:39 +0800 Subject: [PATCH 13/16] Added support for version selection. Pipeline can now specify the version of winappsdk to be used. change to daily midnight build --- .pipelines/UpdateVersions.ps1 | 43 ++++++++++++++++--- .../v2/ci-using-the-latest-winappsdk.yml | 39 ++++++++--------- .pipelines/v2/templates/job-build-project.yml | 18 +++++--- .pipelines/v2/templates/pipeline-ci-build.yml | 9 ++++ ...eps-update-winappsdk-and-restore-nuget.yml | 13 +++++- 5 files changed, 86 insertions(+), 36 deletions(-) diff --git a/.pipelines/UpdateVersions.ps1 b/.pipelines/UpdateVersions.ps1 index 473af6775b67..5ee6551f0848 100644 --- a/.pipelines/UpdateVersions.ps1 +++ b/.pipelines/UpdateVersions.ps1 @@ -1,13 +1,42 @@ +Param( +# Using the default value of 1.6 for versionNumber and useExperimentalVersion as false + #[Parameter(Mandatory=$False,Position=1)] + [string]$versionNumber = "1.6", + + #[Parameter(Mandatory=$False,Position=2)] + [string]$useExperimentalVersion = "false" +) + +# Convert the string parameter to a boolean +$_useExperimentalVersion = [System.Convert]::ToBoolean($useExperimentalVersion) + +$sourceLink = "https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json" + # Execute nuget list and capture the output -$nugetOutput = nuget list Microsoft.WindowsAppSDK ` - -Source "https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json" ` - -AllVersions +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($versionNumber) + $filteredVersions = $nugetOutput | Where-Object { $_ -match "Microsoft.WindowsAppSDK $escapedVersionNumber\." } + $latestVersions = $filteredVersions +} else { + Write-Host "Fetching stable WindowsAppSDK versions for $versionNumber" + $nugetOutput = nuget list Microsoft.WindowsAppSDK ` + -Source $sourceLink ` + -AllVersions + # Filter versions based on the specified version prefix + $escapedVersionNumber = [regex]::Escape($versionNumber) + $filteredVersions = $nugetOutput | Where-Object { $_ -match "Microsoft.WindowsAppSDK $escapedVersionNumber\." } + $latestVersions = $filteredVersions | Sort-Object { [version]($_ -split ' ')[1] } -Descending | Select-Object -First 1 +} -$filteredVersions = $nugetOutput | Where-Object { $_ -match "Microsoft.WindowsAppSDK 1\.6\." } -# Write-Host "Filtered versions: $filteredVersions" -$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]*)' | ` diff --git a/.pipelines/v2/ci-using-the-latest-winappsdk.yml b/.pipelines/v2/ci-using-the-latest-winappsdk.yml index 4db697d19ab2..cc9f00f80d14 100644 --- a/.pipelines/v2/ci-using-the-latest-winappsdk.yml +++ b/.pipelines/v2/ci-using-the-latest-winappsdk.yml @@ -1,25 +1,12 @@ -trigger: - batch: true - branches: - include: - - main - - stable -# paths: -# exclude: -# - doc/* -# - temp/* -# - tools/* -# - '**.md' - -pr: - branches: - include: - - main - - stable -# paths: -# exclude: -# - '**.md' -# - doc +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) @@ -44,6 +31,12 @@ parameters: - 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 @@ -53,3 +46,5 @@ extends: 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 034efdba916d..83cae35b847a 100644 --- a/.pipelines/v2/templates/job-build-project.yml +++ b/.pipelines/v2/templates/job-build-project.yml @@ -59,6 +59,12 @@ parameters: - name: useLatestWinAppSDK type: boolean default: false + - name: winAppSDKVersionNumber + type: string + default: 1.6 + - name: useExperimentalVersion + type: boolean + default: false - name: csProjectsToPublish type: object default: @@ -187,6 +193,9 @@ jobs: - ${{ 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 @@ -245,7 +254,7 @@ jobs: inputs: solution: '**\HostsUILib.csproj' vsVersion: 17.0 - ${{ if eq(parameters.useVSPreview, true) }}: + ${{ if or(eq(parameters.useVSPreview, true), eq(parameters.useLatestWinAppSDK, true)) }}: msbuildArgs: >- /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-hosts.binlog @@ -255,7 +264,6 @@ jobs: msbuildArgs: >- /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-hosts.binlog - $(RestoreAdditionalProjectSourcesArg) configuration: $(BuildConfiguration) msbuildArchitecture: x64 maximumCpuCount: true @@ -268,7 +276,7 @@ jobs: inputs: solution: '**\EnvironmentVariablesUILib.csproj' vsVersion: 17.0 - ${{ if eq(parameters.useVSPreview, true) }}: + ${{ if or(eq(parameters.useVSPreview, true), eq(parameters.useLatestWinAppSDK, true)) }}: msbuildArgs: >- /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-env-var-editor.binlog @@ -278,7 +286,6 @@ jobs: msbuildArgs: >- /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-env-var-editor.binlog - $(RestoreAdditionalProjectSourcesArg) configuration: $(BuildConfiguration) msbuildArchitecture: x64 maximumCpuCount: true @@ -291,7 +298,7 @@ jobs: inputs: solution: '**\RegistryPreviewUILib.csproj' vsVersion: 17.0 - ${{ if eq(parameters.useVSPreview, true) }}: + ${{ if or(eq(parameters.useVSPreview, true), eq(parameters.useLatestWinAppSDK, true)) }}: msbuildArgs: >- /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-registry-preview.binlog @@ -301,7 +308,6 @@ jobs: msbuildArgs: >- /p:CIBuild=true;NoBuild=true -t:pack /bl:$(LogOutputDirectory)\build-registry-preview.binlog - $(RestoreAdditionalProjectSourcesArg) configuration: $(BuildConfiguration) msbuildArchitecture: x64 maximumCpuCount: true diff --git a/.pipelines/v2/templates/pipeline-ci-build.yml b/.pipelines/v2/templates/pipeline-ci-build.yml index 0c184e486cb6..b7db8a7ae101 100644 --- a/.pipelines/v2/templates/pipeline-ci-build.yml +++ b/.pipelines/v2/templates/pipeline-ci-build.yml @@ -25,6 +25,12 @@ parameters: - 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 @@ -59,6 +65,9 @@ stages: 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 index 944dab83c7cc..7adcd262c049 100644 --- a/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml +++ b/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml @@ -1,3 +1,11 @@ +parameters: + - name: versionNumber + type: string + default: 1.6 + - name: useExperimentalVersion + type: boolean + default: false + steps: - task: NuGetAuthenticate@1 displayName: 'NuGet Authenticate' @@ -6,6 +14,9 @@ steps: displayName: Update WinAppSDK Versions inputs: filePath: '$(build.sourcesdirectory)\.pipelines\UpdateVersions.ps1' + arguments: > + -versionNumber ${{ parameters.versionNumber }} + -useExperimentalVersion ${{ parameters.useExperimentalVersion }} - script: echo $(WinAppSDKVersion) displayName: 'Display WinAppSDK Version Found' @@ -17,7 +28,7 @@ steps: project: '55e8140e-57ac-4e5f-8f9c-c7c15b51929d' definition: '104083' buildVersionToDownload: 'latestFromBranch' - branchName: 'refs/heads/release/1.6-stable' + branchName: 'refs/heads/release/${{ parameters.versionNumber }}-stable' artifactName: 'WindowsAppSDK_Nuget_And_MSIX' targetPath: '$(Build.SourcesDirectory)\localpackages' From 6f38b43e85ac94d413c0c7ebd21860d1d5795194 Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Mon, 16 Dec 2024 10:16:36 +0800 Subject: [PATCH 14/16] Add comment explaining why useLatestWinAppSDK needs NOTICE.md not to be verified Signed-off-by: Shawn Yuan --- .pipelines/v2/templates/job-build-project.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pipelines/v2/templates/job-build-project.yml b/.pipelines/v2/templates/job-build-project.yml index 83cae35b847a..5f04ff022e4e 100644 --- a/.pipelines/v2/templates/job-build-project.yml +++ b/.pipelines/v2/templates/job-build-project.yml @@ -457,6 +457,7 @@ jobs: & '.pipelines/verifyPossibleAssetConflicts.ps1' -targetDir '$(build.sourcesdirectory)\$(BuildPlatform)\$(BuildConfiguration)\WinUI3Apps' displayName: Audit WinAppSDK applications path asset conflicts + # 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)\' From 2a9a21d8a9af337bba1cc12a28081d7ea62ae875 Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Tue, 17 Dec 2024 15:29:35 +0800 Subject: [PATCH 15/16] Resolved comments Signed-off-by: Shawn Yuan --- .pipelines/UpdateVersions.ps1 | 65 ++++++++++--------- .pipelines/v2/templates/job-build-project.yml | 45 +++++-------- ...eps-update-winappsdk-and-restore-nuget.yml | 2 +- 3 files changed, 52 insertions(+), 60 deletions(-) diff --git a/.pipelines/UpdateVersions.ps1 b/.pipelines/UpdateVersions.ps1 index 5ee6551f0848..a180999ea882 100644 --- a/.pipelines/UpdateVersions.ps1 +++ b/.pipelines/UpdateVersions.ps1 @@ -1,12 +1,40 @@ Param( -# Using the default value of 1.6 for versionNumber and useExperimentalVersion as false - #[Parameter(Mandatory=$False,Position=1)] - [string]$versionNumber = "1.6", + # Using the default value of 1.6 for winAppSdkVersionNumber and useExperimentalVersion as false + [Parameter(Mandatory=$False,Position=1)] + [string]$winAppSdkVersionNumber = "1.6", - #[Parameter(Mandatory=$False,Position=2)] + # When the pipeline calls the PS1 file, the passed parameters are converted to string type + [Parameter(Mandatory=$False,Position=2)] [string]$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) +} + # Convert the string parameter to a boolean $_useExperimentalVersion = [System.Convert]::ToBoolean($useExperimentalVersion) @@ -22,16 +50,16 @@ if ($_useExperimentalVersion) { -Source $sourceLink ` -Prerelease # Filter versions based on the specified version prefix - $escapedVersionNumber = [regex]::Escape($versionNumber) + $escapedVersionNumber = [regex]::Escape($winAppSdkVersionNumber) $filteredVersions = $nugetOutput | Where-Object { $_ -match "Microsoft.WindowsAppSDK $escapedVersionNumber\." } $latestVersions = $filteredVersions } else { - Write-Host "Fetching stable WindowsAppSDK versions for $versionNumber" + 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($versionNumber) + $escapedVersionNumber = [regex]::Escape($winAppSdkVersionNumber) $filteredVersions = $nugetOutput | Where-Object { $_ -match "Microsoft.WindowsAppSDK $escapedVersionNumber\." } $latestVersions = $filteredVersions | Sort-Object { [version]($_ -split ' ')[1] } -Descending | Select-Object -First 1 } @@ -102,25 +130,4 @@ Get-ChildItem -Recurse *.csproj | ForEach-Object { } } -# Load the nuget.config file -Write-Host "Updating nuget.config file" -$filePath = "nuget.config" -[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) +Update-NugetConfig diff --git a/.pipelines/v2/templates/job-build-project.yml b/.pipelines/v2/templates/job-build-project.yml index 5f04ff022e4e..a83e4c4226bb 100644 --- a/.pipelines/v2/templates/job-build-project.yml +++ b/.pipelines/v2/templates/job-build-project.yml @@ -254,16 +254,11 @@ jobs: inputs: solution: '**\HostsUILib.csproj' vsVersion: 17.0 - ${{ if or(eq(parameters.useVSPreview, true), eq(parameters.useLatestWinAppSDK, true)) }}: - msbuildArgs: >- - /p:CIBuild=true;NoBuild=true -t:pack - /bl:$(LogOutputDirectory)\build-hosts.binlog - /p:NoWarn=NU5104 - $(RestoreAdditionalProjectSourcesArg) - ${{ 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 @@ -276,16 +271,11 @@ jobs: inputs: solution: '**\EnvironmentVariablesUILib.csproj' vsVersion: 17.0 - ${{ if or(eq(parameters.useVSPreview, true), eq(parameters.useLatestWinAppSDK, true)) }}: - msbuildArgs: >- - /p:CIBuild=true;NoBuild=true -t:pack - /bl:$(LogOutputDirectory)\build-env-var-editor.binlog - /p:NoWarn=NU5104 - $(RestoreAdditionalProjectSourcesArg) - ${{ 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 @@ -298,16 +288,11 @@ jobs: inputs: solution: '**\RegistryPreviewUILib.csproj' vsVersion: 17.0 - ${{ if or(eq(parameters.useVSPreview, true), eq(parameters.useLatestWinAppSDK, true)) }}: - msbuildArgs: >- - /p:CIBuild=true;NoBuild=true -t:pack - /bl:$(LogOutputDirectory)\build-registry-preview.binlog - /p:NoWarn=NU5104 - $(RestoreAdditionalProjectSourcesArg) - ${{ 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 diff --git a/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml b/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml index 7adcd262c049..09621968d80b 100644 --- a/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml +++ b/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml @@ -15,7 +15,7 @@ steps: inputs: filePath: '$(build.sourcesdirectory)\.pipelines\UpdateVersions.ps1' arguments: > - -versionNumber ${{ parameters.versionNumber }} + -winAppSdkVersionNumber ${{ parameters.versionNumber }} -useExperimentalVersion ${{ parameters.useExperimentalVersion }} - script: echo $(WinAppSDKVersion) From c1d1e4a47a8e157bdf81927ed41ad5663668c77f Mon Sep 17 00:00:00 2001 From: Shawn Yuan Date: Wed, 18 Dec 2024 08:59:32 +0800 Subject: [PATCH 16/16] resolved comments Signed-off-by: Shawn Yuan --- .pipelines/UpdateVersions.ps1 | 7 ++----- .../templates/steps-update-winappsdk-and-restore-nuget.yml | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.pipelines/UpdateVersions.ps1 b/.pipelines/UpdateVersions.ps1 index a180999ea882..c19dfb5dec07 100644 --- a/.pipelines/UpdateVersions.ps1 +++ b/.pipelines/UpdateVersions.ps1 @@ -5,7 +5,7 @@ Param( # When the pipeline calls the PS1 file, the passed parameters are converted to string type [Parameter(Mandatory=$False,Position=2)] - [string]$useExperimentalVersion = "false" + [boolean]$useExperimentalVersion = $False ) function Update-NugetConfig { @@ -35,13 +35,10 @@ function Update-NugetConfig { $xml.Save($filePath) } -# Convert the string parameter to a boolean -$_useExperimentalVersion = [System.Convert]::ToBoolean($useExperimentalVersion) - $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) { +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 diff --git a/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml b/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml index 09621968d80b..1fccd6de7429 100644 --- a/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml +++ b/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml @@ -16,7 +16,7 @@ steps: filePath: '$(build.sourcesdirectory)\.pipelines\UpdateVersions.ps1' arguments: > -winAppSdkVersionNumber ${{ parameters.versionNumber }} - -useExperimentalVersion ${{ parameters.useExperimentalVersion }} + -useExperimentalVersion $${{ parameters.useExperimentalVersion }} - script: echo $(WinAppSDKVersion) displayName: 'Display WinAppSDK Version Found'