From 5d1ce08963660e8a2a08ffe59815ef0253e3d08b Mon Sep 17 00:00:00 2001 From: David Federman Date: Mon, 15 Jan 2024 13:45:28 -0800 Subject: [PATCH] [Build]Add Microsoft.MSBuildCache (#30100) --- .github/actions/spell-check/expect.txt | 3 ++ .gitignore | 3 ++ .pipelines/ci/caching.yml | 41 ++++++++++++++++ .../ci/templates/build-powertoys-ci.yml | 16 ++++-- .../ci/templates/build-powertoys-steps.yml | 49 +++++++++++++++---- Directory.Build.props | 42 ++++++++++++++++ Directory.Build.targets | 3 ++ packages.config | 6 +++ .../VideoConferenceProxyFilterx86.sln | 10 ++++ 9 files changed, 161 insertions(+), 12 deletions(-) create mode 100644 .pipelines/ci/caching.yml create mode 100644 packages.config diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 09d852ed7c..1ff3718721 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -8,6 +8,7 @@ accctrl Acceleratorkeys ACCEPTFILES ACCESSDENIED +ACCESSTOKEN aclapi AClient AColumn @@ -743,6 +744,7 @@ Knownfolders KSPROPERTY Kybd languagesjson +lastbuildstate lastcodeanalysissucceeded Lastdevice LASTEXITCODE @@ -1273,6 +1275,7 @@ reparented reparenting reparse reportbug +reportfileaccesses requery requerying rescap diff --git a/.gitignore b/.gitignore index 14c1e39737..f8390b9d56 100644 --- a/.gitignore +++ b/.gitignore @@ -348,3 +348,6 @@ src/common/Telemetry/*.etl # Generated installer file for Monaco source files. /installer/PowerToysSetup/MonacoSRC.wxs + +# MSBuildCache +/MSBuildCacheLogs/ diff --git a/.pipelines/ci/caching.yml b/.pipelines/ci/caching.yml new file mode 100644 index 0000000000..b802c9efae --- /dev/null +++ b/.pipelines/ci/caching.yml @@ -0,0 +1,41 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/main/service-schema.json +trigger: + batch: true + branches: + include: + - main + - stable + paths: + exclude: + - doc/* + - temp/* + - tools/* + - '**.md' + +pr: + branches: + include: + - main + - stable + paths: + exclude: + - '**.md' + - doc + +# 0.0.yyMM.dd## +# 0.0.1904.0900 +name: 0.0.$(Date:yyMM).$(Date:dd)$(Rev:rr) + +variables: + EnablePipelineCache: true + +jobs: + - template: ./templates/build-powertoys-precheck.yml + - template: ./templates/build-powertoys-ci.yml + parameters: + platform: x64 + enableCaching: true + - template: ./templates/build-powertoys-ci.yml + parameters: + platform: arm64 + enableCaching: true \ No newline at end of file diff --git a/.pipelines/ci/templates/build-powertoys-ci.yml b/.pipelines/ci/templates/build-powertoys-ci.yml index c5f4882cd8..2d39da65b9 100644 --- a/.pipelines/ci/templates/build-powertoys-ci.yml +++ b/.pipelines/ci/templates/build-powertoys-ci.yml @@ -1,7 +1,16 @@ parameters: - configuration: 'Release' - platform: '' - additionalBuildArguments: '/p:RestorePackagesConfig=true -m' + - name: configuration + type: string + default: 'Release' + - name: platform + type: string + default: '/p:RestorePackagesConfig=true -m' + - name: additionalBuildArguments + type: string + default: '/p:RestorePackagesConfig=true -m' + - name: enableCaching + type: boolean + default: false jobs: - job: Build${{ parameters.platform }}${{ parameters.configuration }} @@ -26,6 +35,7 @@ jobs: - template: build-powertoys-steps.yml parameters: additionalBuildArguments: ${{ parameters.additionalBuildArguments }} + enableCaching: ${{ parameters.enableCaching }} # It appears that the Component Governance build task that gets automatically injected stopped working # when we renamed our main branch. diff --git a/.pipelines/ci/templates/build-powertoys-steps.yml b/.pipelines/ci/templates/build-powertoys-steps.yml index d151a39257..8152927111 100644 --- a/.pipelines/ci/templates/build-powertoys-steps.yml +++ b/.pipelines/ci/templates/build-powertoys-steps.yml @@ -1,5 +1,10 @@ parameters: - additionalBuildArguments: '' + - name: additionalBuildArguments + type: string + default: '' + - name: enableCaching + type: boolean + default: false steps: - checkout: self @@ -78,6 +83,13 @@ steps: - task: VisualStudioTestPlatformInstaller@1 displayName: Ensure VSTest Platform +- ${{ if eq(parameters.enableCaching, true) }}: + - task: NuGetToolInstaller@1 + displayName: Install NuGet + + - script: nuget restore packages.config -SolutionDirectory . + displayName: 'nuget restore packages.config' + - task: VSBuild@1 displayName: 'Build PowerToys.sln' inputs: @@ -85,8 +97,15 @@ steps: vsVersion: 17.0 platform: '$(BuildPlatform)' configuration: '$(BuildConfiguration)' - msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} + ${{ if eq(parameters.enableCaching, true) }}: + msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -graph -reportfileaccesses -p:MSBuildCacheEnabled=true -p:MSBuildCacheLogDirectory=$(Build.ArtifactStagingDirectory)\logs\MSBuildCache -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToys.binlog -ds:false + ${{ else }}: + msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToys.binlog -ds:false + msbuildArchitecture: x64 maximumCpuCount: true + ${{ if eq(parameters.enableCaching, true) }}: + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) - task: VSBuild@1 displayName: 'Build BugReportTool.sln' @@ -95,7 +114,8 @@ steps: vsVersion: 17.0 platform: '$(BuildPlatform)' configuration: '$(BuildConfiguration)' - msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} + msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\BugReportTool.binlog -ds:false + msbuildArchitecture: x64 maximumCpuCount: true - task: VSBuild@1 @@ -105,7 +125,8 @@ steps: vsVersion: 17.0 platform: '$(BuildPlatform)' configuration: '$(BuildConfiguration)' - msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} + msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\WebcamReportTool.binlog -ds:false + msbuildArchitecture: x64 maximumCpuCount: true - task: VSBuild@1 @@ -115,7 +136,8 @@ steps: vsVersion: 17.0 platform: '$(BuildPlatform)' configuration: '$(BuildConfiguration)' - msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} + msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\StylesReportTool.binlog -ds:false + msbuildArchitecture: x64 maximumCpuCount: true - task: PowerShell@2 @@ -131,7 +153,8 @@ steps: vsVersion: 17.0 platform: '$(BuildPlatform)' configuration: '$(BuildConfiguration)' - msbuildArgs: /t:PowerToysInstaller -restore ${{ parameters.additionalBuildArguments }} + msbuildArgs: /t:PowerToysInstaller -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToysSetup-PowerToysInstaller.binlog -ds:false + msbuildArchitecture: x64 maximumCpuCount: true - task: VSBuild@1 @@ -141,8 +164,9 @@ steps: vsVersion: 17.0 platform: '$(BuildPlatform)' configuration: '$(BuildConfiguration)' - msbuildArgs: /t:PowerToysBootstrapper ${{ parameters.additionalBuildArguments }} + msbuildArgs: /t:PowerToysBootstrapper ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToysSetup-PowerToysBootstrapper.binlog -ds:false clean: false + msbuildArchitecture: x64 maximumCpuCount: true - task: PowerShell@2 @@ -159,7 +183,8 @@ steps: vsVersion: 17.0 platform: '$(BuildPlatform)' configuration: '$(BuildConfiguration)' - msbuildArgs: /t:PowerToysInstaller -restore ${{ parameters.additionalBuildArguments }} /p:PerUser=true + msbuildArgs: /t:PowerToysInstaller -restore ${{ parameters.additionalBuildArguments }} /p:PerUser=true -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToysSetup-PowerToysInstaller-PerUser.binlog -ds:false + msbuildArchitecture: x64 maximumCpuCount: true - task: VSBuild@1 @@ -169,8 +194,9 @@ steps: vsVersion: 17.0 platform: '$(BuildPlatform)' configuration: '$(BuildConfiguration)' - msbuildArgs: /t:PowerToysBootstrapper ${{ parameters.additionalBuildArguments }} /p:PerUser=true + msbuildArgs: /t:PowerToysBootstrapper ${{ parameters.additionalBuildArguments }} /p:PerUser=true -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToysSetup-PowerToysBootstrapper-PerUser.binlog -ds:false clean: false + msbuildArchitecture: x64 maximumCpuCount: true # Check if deps.json files don't reference different dll versions. @@ -268,3 +294,8 @@ steps: filePath: '$(build.sourcesdirectory)\.pipelines\verifyNoticeMdAgainstNugetPackages.ps1' arguments: -path '$(build.sourcesdirectory)\' pwsh: true + +- publish: $(Build.ArtifactStagingDirectory)\logs + displayName: Publish Logs + artifact: '$(System.JobDisplayName) logs' + condition: always() diff --git a/Directory.Build.props b/Directory.Build.props index bc0da728c2..14a45385d4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -44,4 +44,46 @@ + + + + false + + + Microsoft.MSBuildCache.AzurePipelines + Microsoft.MSBuildCache.Local + + + + + 202310210737 + + + $(MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns);packages\Microsoft.WindowsAppSDK.*\tools\net472\ApplicationInsights.config + + + $(MSBuildCacheIdenticalDuplicateOutputPatterns);** + + + $(MSBuildThisFileDirectory)packages.config + $(MSBuildCacheIgnoredInputPatterns);$(PackagesConfigFile) + + + + $([System.IO.File]::ReadAllText("$(PackagesConfigFile)")) + $([System.Text.RegularExpressions.Regex]::Match($(PackagesConfigContents), 'Microsoft.MSBuildCache.*?version="(.*?)"').Groups[1].Value) + $(MSBuildThisFileDirectory)packages\$(MSBuildCachePackageName).$(MSBuildCachePackageVersion) + $(MSBuildThisFileDirectory)packages\Microsoft.MSBuildCache.SharedCompilation.$(MSBuildCachePackageVersion) + + + + + + \ No newline at end of file diff --git a/Directory.Build.targets b/Directory.Build.targets index 66a8733ce6..cba7762d5f 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,3 +1,6 @@ + + + \ No newline at end of file diff --git a/packages.config b/packages.config new file mode 100644 index 0000000000..c99cd91fd7 --- /dev/null +++ b/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilterx86.sln b/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilterx86.sln index e61fcf0bd6..e4f5a92176 100644 --- a/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilterx86.sln +++ b/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilterx86.sln @@ -7,6 +7,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceProxyFilter" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceShared", "..\VideoConferenceShared\VideoConferenceShared.vcxproj", "{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Version", "..\..\..\common\version\version.vcxproj", "{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -31,6 +33,14 @@ Global {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|Win32.Build.0 = Release|Win32 {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.ActiveCfg = Release|x64 {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.Build.0 = Release|x64 + {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|Win32.ActiveCfg = Debug|Win32 + {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|Win32.Build.0 = Debug|Win32 + {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|x64.ActiveCfg = Debug|x64 + {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|x64.Build.0 = Debug|x64 + {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|Win32.ActiveCfg = Release|Win32 + {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|Win32.Build.0 = Release|Win32 + {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|x64.ActiveCfg = Release|x64 + {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE