[Build]Add Microsoft.MSBuildCache (#30100)

This commit is contained in:
David Federman 2024-01-15 13:45:28 -08:00 committed by GitHub
parent b609cf614d
commit 5d1ce08963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 161 additions and 12 deletions

View File

@ -8,6 +8,7 @@ accctrl
Acceleratorkeys Acceleratorkeys
ACCEPTFILES ACCEPTFILES
ACCESSDENIED ACCESSDENIED
ACCESSTOKEN
aclapi aclapi
AClient AClient
AColumn AColumn
@ -743,6 +744,7 @@ Knownfolders
KSPROPERTY KSPROPERTY
Kybd Kybd
languagesjson languagesjson
lastbuildstate
lastcodeanalysissucceeded lastcodeanalysissucceeded
Lastdevice Lastdevice
LASTEXITCODE LASTEXITCODE
@ -1273,6 +1275,7 @@ reparented
reparenting reparenting
reparse reparse
reportbug reportbug
reportfileaccesses
requery requery
requerying requerying
rescap rescap

3
.gitignore vendored
View File

@ -348,3 +348,6 @@ src/common/Telemetry/*.etl
# Generated installer file for Monaco source files. # Generated installer file for Monaco source files.
/installer/PowerToysSetup/MonacoSRC.wxs /installer/PowerToysSetup/MonacoSRC.wxs
# MSBuildCache
/MSBuildCacheLogs/

41
.pipelines/ci/caching.yml Normal file
View File

@ -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

View File

@ -1,7 +1,16 @@
parameters: parameters:
configuration: 'Release' - name: configuration
platform: '' type: string
additionalBuildArguments: '/p:RestorePackagesConfig=true -m' 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: jobs:
- job: Build${{ parameters.platform }}${{ parameters.configuration }} - job: Build${{ parameters.platform }}${{ parameters.configuration }}
@ -26,6 +35,7 @@ jobs:
- template: build-powertoys-steps.yml - template: build-powertoys-steps.yml
parameters: parameters:
additionalBuildArguments: ${{ parameters.additionalBuildArguments }} additionalBuildArguments: ${{ parameters.additionalBuildArguments }}
enableCaching: ${{ parameters.enableCaching }}
# It appears that the Component Governance build task that gets automatically injected stopped working # It appears that the Component Governance build task that gets automatically injected stopped working
# when we renamed our main branch. # when we renamed our main branch.

View File

@ -1,5 +1,10 @@
parameters: parameters:
additionalBuildArguments: '' - name: additionalBuildArguments
type: string
default: ''
- name: enableCaching
type: boolean
default: false
steps: steps:
- checkout: self - checkout: self
@ -78,6 +83,13 @@ steps:
- task: VisualStudioTestPlatformInstaller@1 - task: VisualStudioTestPlatformInstaller@1
displayName: Ensure VSTest Platform 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 - task: VSBuild@1
displayName: 'Build PowerToys.sln' displayName: 'Build PowerToys.sln'
inputs: inputs:
@ -85,8 +97,15 @@ steps:
vsVersion: 17.0 vsVersion: 17.0
platform: '$(BuildPlatform)' platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)' 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 maximumCpuCount: true
${{ if eq(parameters.enableCaching, true) }}:
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
- task: VSBuild@1 - task: VSBuild@1
displayName: 'Build BugReportTool.sln' displayName: 'Build BugReportTool.sln'
@ -95,7 +114,8 @@ steps:
vsVersion: 17.0 vsVersion: 17.0
platform: '$(BuildPlatform)' platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)' configuration: '$(BuildConfiguration)'
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\BugReportTool.binlog -ds:false
msbuildArchitecture: x64
maximumCpuCount: true maximumCpuCount: true
- task: VSBuild@1 - task: VSBuild@1
@ -105,7 +125,8 @@ steps:
vsVersion: 17.0 vsVersion: 17.0
platform: '$(BuildPlatform)' platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)' configuration: '$(BuildConfiguration)'
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\WebcamReportTool.binlog -ds:false
msbuildArchitecture: x64
maximumCpuCount: true maximumCpuCount: true
- task: VSBuild@1 - task: VSBuild@1
@ -115,7 +136,8 @@ steps:
vsVersion: 17.0 vsVersion: 17.0
platform: '$(BuildPlatform)' platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)' configuration: '$(BuildConfiguration)'
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\StylesReportTool.binlog -ds:false
msbuildArchitecture: x64
maximumCpuCount: true maximumCpuCount: true
- task: PowerShell@2 - task: PowerShell@2
@ -131,7 +153,8 @@ steps:
vsVersion: 17.0 vsVersion: 17.0
platform: '$(BuildPlatform)' platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)' 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 maximumCpuCount: true
- task: VSBuild@1 - task: VSBuild@1
@ -141,8 +164,9 @@ steps:
vsVersion: 17.0 vsVersion: 17.0
platform: '$(BuildPlatform)' platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)' configuration: '$(BuildConfiguration)'
msbuildArgs: /t:PowerToysBootstrapper ${{ parameters.additionalBuildArguments }} msbuildArgs: /t:PowerToysBootstrapper ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToysSetup-PowerToysBootstrapper.binlog -ds:false
clean: false clean: false
msbuildArchitecture: x64
maximumCpuCount: true maximumCpuCount: true
- task: PowerShell@2 - task: PowerShell@2
@ -159,7 +183,8 @@ steps:
vsVersion: 17.0 vsVersion: 17.0
platform: '$(BuildPlatform)' platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)' 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 maximumCpuCount: true
- task: VSBuild@1 - task: VSBuild@1
@ -169,8 +194,9 @@ steps:
vsVersion: 17.0 vsVersion: 17.0
platform: '$(BuildPlatform)' platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)' 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 clean: false
msbuildArchitecture: x64
maximumCpuCount: true maximumCpuCount: true
# Check if deps.json files don't reference different dll versions. # Check if deps.json files don't reference different dll versions.
@ -268,3 +294,8 @@ steps:
filePath: '$(build.sourcesdirectory)\.pipelines\verifyNoticeMdAgainstNugetPackages.ps1' filePath: '$(build.sourcesdirectory)\.pipelines\verifyNoticeMdAgainstNugetPackages.ps1'
arguments: -path '$(build.sourcesdirectory)\' arguments: -path '$(build.sourcesdirectory)\'
pwsh: true pwsh: true
- publish: $(Build.ArtifactStagingDirectory)\logs
displayName: Publish Logs
artifact: '$(System.JobDisplayName) logs'
condition: always()

View File

@ -44,4 +44,46 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<!-- MSBuildCache -->
<PropertyGroup>
<!-- Off by default -->
<MSBuildCacheEnabled Condition="'$(MSBuildCacheEnabled)' == ''">false</MSBuildCacheEnabled>
<!-- In Azure pipelines, use Pipeline Caching as the cache storage backend. Otherwise, use the local cache. -->
<MSBuildCachePackageName Condition="'$(TF_BUILD)' != ''">Microsoft.MSBuildCache.AzurePipelines</MSBuildCachePackageName>
<MSBuildCachePackageName Condition="'$(MSBuildCachePackageName)' == ''">Microsoft.MSBuildCache.Local</MSBuildCachePackageName>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildCacheEnabled)' == 'true'">
<!-- Change this to bust the cache -->
<MSBuildCacheCacheUniverse Condition="'$(MSBuildCacheCacheUniverse)' == ''">202310210737</MSBuildCacheCacheUniverse>
<!--
A tool inside Microsoft.WindowsAppSDK uses AppInsights which appears to read packages\Microsoft.WindowsAppSDK.1.4.230913002\tools\net472\ApplicationInsights.config
after the project is finished, likely in a detached process. This is acceptable and should not impact cache correctness.
-->
<MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns>$(MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns);packages\Microsoft.WindowsAppSDK.*\tools\net472\ApplicationInsights.config</MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns>
<!--
This repo uses a common output directory with many projects writing duplicate outputs. Allow everything, but note this costs some performance in the form of requiring
the cache to use copies instead of hardlinks when pulling from cache.
-->
<MSBuildCacheIdenticalDuplicateOutputPatterns>$(MSBuildCacheIdenticalDuplicateOutputPatterns);**</MSBuildCacheIdenticalDuplicateOutputPatterns>
<!-- version of MSBuildCache is not part of the cache key -->
<PackagesConfigFile>$(MSBuildThisFileDirectory)packages.config</PackagesConfigFile>
<MSBuildCacheIgnoredInputPatterns>$(MSBuildCacheIgnoredInputPatterns);$(PackagesConfigFile)</MSBuildCacheIgnoredInputPatterns>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildCacheEnabled)' == 'true' and '$(MSBuildCachePackageRoot)' == ''">
<PackagesConfigContents>$([System.IO.File]::ReadAllText("$(PackagesConfigFile)"))</PackagesConfigContents>
<MSBuildCachePackageVersion>$([System.Text.RegularExpressions.Regex]::Match($(PackagesConfigContents), 'Microsoft.MSBuildCache.*?version="(.*?)"').Groups[1].Value)</MSBuildCachePackageVersion>
<MSBuildCachePackageRoot>$(MSBuildThisFileDirectory)packages\$(MSBuildCachePackageName).$(MSBuildCachePackageVersion)</MSBuildCachePackageRoot>
<MSBuildCacheSharedCompilationPackageRoot>$(MSBuildThisFileDirectory)packages\Microsoft.MSBuildCache.SharedCompilation.$(MSBuildCachePackageVersion)</MSBuildCacheSharedCompilationPackageRoot>
</PropertyGroup>
<ImportGroup Condition="'$(MSBuildCacheEnabled)' == 'true'">
<Import Project="$(MSBuildCachePackageRoot)\build\$(MSBuildCachePackageName).props" />
<Import Project="$(MSBuildCacheSharedCompilationPackageRoot)\build\Microsoft.MSBuildCache.SharedCompilation.props" />
</ImportGroup>
</Project> </Project>

View File

@ -1,3 +1,6 @@
<Project> <Project>
<Sdk Name="Microsoft.Build.CopyOnWrite" Version="1.0.282" /> <Sdk Name="Microsoft.Build.CopyOnWrite" Version="1.0.282" />
<Import Project="$(MSBuildCachePackageRoot)\build\$(MSBuildCachePackageName).targets" Condition="'$(MSBuildCacheEnabled)' == 'true'" />
<Import Project="$(MSBuildCacheSharedCompilationPackageRoot)\build\Microsoft.MSBuildCache.SharedCompilation.targets" Condition="'$(MSBuildCacheEnabled)' == 'true'" />
</Project> </Project>

6
packages.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.236-preview" />
<package id="Microsoft.MSBuildCache.Local" version="0.1.236-preview" />
<package id="Microsoft.MSBuildCache.SharedCompilation" version="0.1.236-preview" />
</packages>

View File

@ -7,6 +7,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceProxyFilter"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceShared", "..\VideoConferenceShared\VideoConferenceShared.vcxproj", "{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceShared", "..\VideoConferenceShared\VideoConferenceShared.vcxproj", "{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Version", "..\..\..\common\version\version.vcxproj", "{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 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|Win32.Build.0 = Release|Win32
{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.ActiveCfg = Release|x64 {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.ActiveCfg = Release|x64
{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE