Skip to content

Commit 5d1ce08

Browse files
authored
[Build]Add Microsoft.MSBuildCache (#30100)
1 parent b609cf6 commit 5d1ce08

File tree

9 files changed

+161
-12
lines changed

9 files changed

+161
-12
lines changed

.github/actions/spell-check/expect.txt

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ accctrl
88
Acceleratorkeys
99
ACCEPTFILES
1010
ACCESSDENIED
11+
ACCESSTOKEN
1112
aclapi
1213
AClient
1314
AColumn
@@ -743,6 +744,7 @@ Knownfolders
743744
KSPROPERTY
744745
Kybd
745746
languagesjson
747+
lastbuildstate
746748
lastcodeanalysissucceeded
747749
Lastdevice
748750
LASTEXITCODE
@@ -1273,6 +1275,7 @@ reparented
12731275
reparenting
12741276
reparse
12751277
reportbug
1278+
reportfileaccesses
12761279
requery
12771280
requerying
12781281
rescap

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,6 @@ src/common/Telemetry/*.etl
348348

349349
# Generated installer file for Monaco source files.
350350
/installer/PowerToysSetup/MonacoSRC.wxs
351+
352+
# MSBuildCache
353+
/MSBuildCacheLogs/

.pipelines/ci/caching.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/main/service-schema.json
2+
trigger:
3+
batch: true
4+
branches:
5+
include:
6+
- main
7+
- stable
8+
paths:
9+
exclude:
10+
- doc/*
11+
- temp/*
12+
- tools/*
13+
- '**.md'
14+
15+
pr:
16+
branches:
17+
include:
18+
- main
19+
- stable
20+
paths:
21+
exclude:
22+
- '**.md'
23+
- doc
24+
25+
# 0.0.yyMM.dd##
26+
# 0.0.1904.0900
27+
name: 0.0.$(Date:yyMM).$(Date:dd)$(Rev:rr)
28+
29+
variables:
30+
EnablePipelineCache: true
31+
32+
jobs:
33+
- template: ./templates/build-powertoys-precheck.yml
34+
- template: ./templates/build-powertoys-ci.yml
35+
parameters:
36+
platform: x64
37+
enableCaching: true
38+
- template: ./templates/build-powertoys-ci.yml
39+
parameters:
40+
platform: arm64
41+
enableCaching: true

.pipelines/ci/templates/build-powertoys-ci.yml

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
parameters:
2-
configuration: 'Release'
3-
platform: ''
4-
additionalBuildArguments: '/p:RestorePackagesConfig=true -m'
2+
- name: configuration
3+
type: string
4+
default: 'Release'
5+
- name: platform
6+
type: string
7+
default: '/p:RestorePackagesConfig=true -m'
8+
- name: additionalBuildArguments
9+
type: string
10+
default: '/p:RestorePackagesConfig=true -m'
11+
- name: enableCaching
12+
type: boolean
13+
default: false
514

615
jobs:
716
- job: Build${{ parameters.platform }}${{ parameters.configuration }}
@@ -26,6 +35,7 @@ jobs:
2635
- template: build-powertoys-steps.yml
2736
parameters:
2837
additionalBuildArguments: ${{ parameters.additionalBuildArguments }}
38+
enableCaching: ${{ parameters.enableCaching }}
2939

3040
# It appears that the Component Governance build task that gets automatically injected stopped working
3141
# when we renamed our main branch.

.pipelines/ci/templates/build-powertoys-steps.yml

+40-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
parameters:
2-
additionalBuildArguments: ''
2+
- name: additionalBuildArguments
3+
type: string
4+
default: ''
5+
- name: enableCaching
6+
type: boolean
7+
default: false
38

49
steps:
510
- checkout: self
@@ -78,15 +83,29 @@ steps:
7883
- task: VisualStudioTestPlatformInstaller@1
7984
displayName: Ensure VSTest Platform
8085

86+
- ${{ if eq(parameters.enableCaching, true) }}:
87+
- task: NuGetToolInstaller@1
88+
displayName: Install NuGet
89+
90+
- script: nuget restore packages.config -SolutionDirectory .
91+
displayName: 'nuget restore packages.config'
92+
8193
- task: VSBuild@1
8294
displayName: 'Build PowerToys.sln'
8395
inputs:
8496
solution: '**\PowerToys.sln'
8597
vsVersion: 17.0
8698
platform: '$(BuildPlatform)'
8799
configuration: '$(BuildConfiguration)'
88-
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }}
100+
${{ if eq(parameters.enableCaching, true) }}:
101+
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -graph -reportfileaccesses -p:MSBuildCacheEnabled=true -p:MSBuildCacheLogDirectory=$(Build.ArtifactStagingDirectory)\logs\MSBuildCache -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToys.binlog -ds:false
102+
${{ else }}:
103+
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToys.binlog -ds:false
104+
msbuildArchitecture: x64
89105
maximumCpuCount: true
106+
${{ if eq(parameters.enableCaching, true) }}:
107+
env:
108+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
90109

91110
- task: VSBuild@1
92111
displayName: 'Build BugReportTool.sln'
@@ -95,7 +114,8 @@ steps:
95114
vsVersion: 17.0
96115
platform: '$(BuildPlatform)'
97116
configuration: '$(BuildConfiguration)'
98-
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }}
117+
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\BugReportTool.binlog -ds:false
118+
msbuildArchitecture: x64
99119
maximumCpuCount: true
100120

101121
- task: VSBuild@1
@@ -105,7 +125,8 @@ steps:
105125
vsVersion: 17.0
106126
platform: '$(BuildPlatform)'
107127
configuration: '$(BuildConfiguration)'
108-
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }}
128+
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\WebcamReportTool.binlog -ds:false
129+
msbuildArchitecture: x64
109130
maximumCpuCount: true
110131

111132
- task: VSBuild@1
@@ -115,7 +136,8 @@ steps:
115136
vsVersion: 17.0
116137
platform: '$(BuildPlatform)'
117138
configuration: '$(BuildConfiguration)'
118-
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }}
139+
msbuildArgs: -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\StylesReportTool.binlog -ds:false
140+
msbuildArchitecture: x64
119141
maximumCpuCount: true
120142

121143
- task: PowerShell@2
@@ -131,7 +153,8 @@ steps:
131153
vsVersion: 17.0
132154
platform: '$(BuildPlatform)'
133155
configuration: '$(BuildConfiguration)'
134-
msbuildArgs: /t:PowerToysInstaller -restore ${{ parameters.additionalBuildArguments }}
156+
msbuildArgs: /t:PowerToysInstaller -restore ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToysSetup-PowerToysInstaller.binlog -ds:false
157+
msbuildArchitecture: x64
135158
maximumCpuCount: true
136159

137160
- task: VSBuild@1
@@ -141,8 +164,9 @@ steps:
141164
vsVersion: 17.0
142165
platform: '$(BuildPlatform)'
143166
configuration: '$(BuildConfiguration)'
144-
msbuildArgs: /t:PowerToysBootstrapper ${{ parameters.additionalBuildArguments }}
167+
msbuildArgs: /t:PowerToysBootstrapper ${{ parameters.additionalBuildArguments }} -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToysSetup-PowerToysBootstrapper.binlog -ds:false
145168
clean: false
169+
msbuildArchitecture: x64
146170
maximumCpuCount: true
147171

148172
- task: PowerShell@2
@@ -159,7 +183,8 @@ steps:
159183
vsVersion: 17.0
160184
platform: '$(BuildPlatform)'
161185
configuration: '$(BuildConfiguration)'
162-
msbuildArgs: /t:PowerToysInstaller -restore ${{ parameters.additionalBuildArguments }} /p:PerUser=true
186+
msbuildArgs: /t:PowerToysInstaller -restore ${{ parameters.additionalBuildArguments }} /p:PerUser=true -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToysSetup-PowerToysInstaller-PerUser.binlog -ds:false
187+
msbuildArchitecture: x64
163188
maximumCpuCount: true
164189

165190
- task: VSBuild@1
@@ -169,8 +194,9 @@ steps:
169194
vsVersion: 17.0
170195
platform: '$(BuildPlatform)'
171196
configuration: '$(BuildConfiguration)'
172-
msbuildArgs: /t:PowerToysBootstrapper ${{ parameters.additionalBuildArguments }} /p:PerUser=true
197+
msbuildArgs: /t:PowerToysBootstrapper ${{ parameters.additionalBuildArguments }} /p:PerUser=true -bl:$(Build.ArtifactStagingDirectory)\logs\PowerToysSetup-PowerToysBootstrapper-PerUser.binlog -ds:false
173198
clean: false
199+
msbuildArchitecture: x64
174200
maximumCpuCount: true
175201

176202
# Check if deps.json files don't reference different dll versions.
@@ -268,3 +294,8 @@ steps:
268294
filePath: '$(build.sourcesdirectory)\.pipelines\verifyNoticeMdAgainstNugetPackages.ps1'
269295
arguments: -path '$(build.sourcesdirectory)\'
270296
pwsh: true
297+
298+
- publish: $(Build.ArtifactStagingDirectory)\logs
299+
displayName: Publish Logs
300+
artifact: '$(System.JobDisplayName) logs'
301+
condition: always()

Directory.Build.props

+42
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,46 @@
4444
</PackageReference>
4545
</ItemGroup>
4646

47+
<!-- MSBuildCache -->
48+
<PropertyGroup>
49+
<!-- Off by default -->
50+
<MSBuildCacheEnabled Condition="'$(MSBuildCacheEnabled)' == ''">false</MSBuildCacheEnabled>
51+
52+
<!-- In Azure pipelines, use Pipeline Caching as the cache storage backend. Otherwise, use the local cache. -->
53+
<MSBuildCachePackageName Condition="'$(TF_BUILD)' != ''">Microsoft.MSBuildCache.AzurePipelines</MSBuildCachePackageName>
54+
<MSBuildCachePackageName Condition="'$(MSBuildCachePackageName)' == ''">Microsoft.MSBuildCache.Local</MSBuildCachePackageName>
55+
</PropertyGroup>
56+
57+
<PropertyGroup Condition="'$(MSBuildCacheEnabled)' == 'true'">
58+
<!-- Change this to bust the cache -->
59+
<MSBuildCacheCacheUniverse Condition="'$(MSBuildCacheCacheUniverse)' == ''">202310210737</MSBuildCacheCacheUniverse>
60+
61+
<!--
62+
A tool inside Microsoft.WindowsAppSDK uses AppInsights which appears to read packages\Microsoft.WindowsAppSDK.1.4.230913002\tools\net472\ApplicationInsights.config
63+
after the project is finished, likely in a detached process. This is acceptable and should not impact cache correctness.
64+
-->
65+
<MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns>$(MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns);packages\Microsoft.WindowsAppSDK.*\tools\net472\ApplicationInsights.config</MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns>
66+
67+
<!--
68+
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
69+
the cache to use copies instead of hardlinks when pulling from cache.
70+
-->
71+
<MSBuildCacheIdenticalDuplicateOutputPatterns>$(MSBuildCacheIdenticalDuplicateOutputPatterns);**</MSBuildCacheIdenticalDuplicateOutputPatterns>
72+
73+
<!-- version of MSBuildCache is not part of the cache key -->
74+
<PackagesConfigFile>$(MSBuildThisFileDirectory)packages.config</PackagesConfigFile>
75+
<MSBuildCacheIgnoredInputPatterns>$(MSBuildCacheIgnoredInputPatterns);$(PackagesConfigFile)</MSBuildCacheIgnoredInputPatterns>
76+
</PropertyGroup>
77+
78+
<PropertyGroup Condition="'$(MSBuildCacheEnabled)' == 'true' and '$(MSBuildCachePackageRoot)' == ''">
79+
<PackagesConfigContents>$([System.IO.File]::ReadAllText("$(PackagesConfigFile)"))</PackagesConfigContents>
80+
<MSBuildCachePackageVersion>$([System.Text.RegularExpressions.Regex]::Match($(PackagesConfigContents), 'Microsoft.MSBuildCache.*?version="(.*?)"').Groups[1].Value)</MSBuildCachePackageVersion>
81+
<MSBuildCachePackageRoot>$(MSBuildThisFileDirectory)packages\$(MSBuildCachePackageName).$(MSBuildCachePackageVersion)</MSBuildCachePackageRoot>
82+
<MSBuildCacheSharedCompilationPackageRoot>$(MSBuildThisFileDirectory)packages\Microsoft.MSBuildCache.SharedCompilation.$(MSBuildCachePackageVersion)</MSBuildCacheSharedCompilationPackageRoot>
83+
</PropertyGroup>
84+
85+
<ImportGroup Condition="'$(MSBuildCacheEnabled)' == 'true'">
86+
<Import Project="$(MSBuildCachePackageRoot)\build\$(MSBuildCachePackageName).props" />
87+
<Import Project="$(MSBuildCacheSharedCompilationPackageRoot)\build\Microsoft.MSBuildCache.SharedCompilation.props" />
88+
</ImportGroup>
4789
</Project>

Directory.Build.targets

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
<Project>
22
<Sdk Name="Microsoft.Build.CopyOnWrite" Version="1.0.282" />
3+
4+
<Import Project="$(MSBuildCachePackageRoot)\build\$(MSBuildCachePackageName).targets" Condition="'$(MSBuildCacheEnabled)' == 'true'" />
5+
<Import Project="$(MSBuildCacheSharedCompilationPackageRoot)\build\Microsoft.MSBuildCache.SharedCompilation.targets" Condition="'$(MSBuildCacheEnabled)' == 'true'" />
36
</Project>

packages.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.236-preview" />
4+
<package id="Microsoft.MSBuildCache.Local" version="0.1.236-preview" />
5+
<package id="Microsoft.MSBuildCache.SharedCompilation" version="0.1.236-preview" />
6+
</packages>

src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilterx86.sln

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceProxyFilter"
77
EndProject
88
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceShared", "..\VideoConferenceShared\VideoConferenceShared.vcxproj", "{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}"
99
EndProject
10+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Version", "..\..\..\common\version\version.vcxproj", "{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Win32 = Debug|Win32
@@ -31,6 +33,14 @@ Global
3133
{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|Win32.Build.0 = Release|Win32
3234
{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.ActiveCfg = Release|x64
3335
{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.Build.0 = Release|x64
36+
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|Win32.ActiveCfg = Debug|Win32
37+
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|Win32.Build.0 = Debug|Win32
38+
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|x64.ActiveCfg = Debug|x64
39+
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|x64.Build.0 = Debug|x64
40+
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|Win32.ActiveCfg = Release|Win32
41+
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|Win32.Build.0 = Release|Win32
42+
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|x64.ActiveCfg = Release|x64
43+
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|x64.Build.0 = Release|x64
3444
EndGlobalSection
3545
GlobalSection(SolutionProperties) = preSolution
3646
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)