@@ -68,6 +68,9 @@ parameters:
6868 - name: signingIdentity
6969 type: object
7070 default: {}
71+ - name: enableCaching
72+ type: boolean
73+ default: false
7174
7275jobs:
7376- job: ${{ parameters.jobName }}
9598 # Yup.
9699 BuildTargetParameter: ' '
97100 SelectedSigningFragments: ' '
101+ MSBuildCacheParameters: ' '
98102 # When building the unpackaged distribution, build it in portable mode if it's Canary-branded
99103 ${{ if eq(parameters.branding, 'Canary') }}:
100104 UnpackagedBuildArguments: -PortableMode
@@ -111,6 +115,7 @@ jobs:
111115 clean: true
112116 submodules: true
113117 persistCredentials: True
118+
114119 # This generates either nothing for BuildTargetParameter, or /t:X;Y;Z, to control targets later.
115120 - pwsh: |-
116121 If (-Not [bool]::Parse("${{ parameters.buildEverything }}")) {
@@ -139,6 +144,17 @@ jobs:
139144 }
140145 displayName: Prepare Build and Sign Targets
141146
147+ - ${{ if eq(parameters.enableCaching, true) }}:
148+ - pwsh: |-
149+ $MSBuildCacheParameters = ""
150+ $MSBuildCacheParameters += " -graph"
151+ $MSBuildCacheParameters += " -reportfileaccesses"
152+ $MSBuildCacheParameters += " -p:MSBuildCacheEnabled=true"
153+ $MSBuildCacheParameters += " -p:MSBuildCacheLogDirectory=$(Build.SourcesDirectory)\MSBuildCacheLogs"
154+ Write-Host "MSBuildCacheParameters: $MSBuildCacheParameters"
155+ Write-Host "##vso[task.setvariable variable=MSBuildCacheParameters]$MSBuildCacheParameters"
156+ displayName: Prepare MSBuildCache variables
157+
142158 - pwsh: |-
143159 .\build\scripts\Generate-ThirdPartyNotices.ps1 -MarkdownNoticePath .\NOTICE.md -OutputPath .\src\cascadia\CascadiaPackage\NOTICE.html
144160 displayName: Generate NOTICE.html from NOTICE.md
@@ -160,21 +176,37 @@ jobs:
160176 ${{ parameters.additionalBuildOptions }}
161177 /bl:$(Build.SourcesDirectory)\msbuild.binlog
162178 $(BuildTargetParameter)
179+ $(MSBuildCacheParameters)
163180 platform: $(BuildPlatform)
164181 configuration: $(BuildConfiguration)
182+ msbuildArchitecture: x64
165183 maximumCpuCount: true
184+ ${{ if eq(parameters.enableCaching, true) }}:
185+ env:
186+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
166187
167188 - ${{ if eq(parameters.publishArtifacts, true) }}:
168189 - publish: $(Build.SourcesDirectory)/msbuild.binlog
169190 artifact: logs-$(BuildPlatform)-$(BuildConfiguration)${{ parameters.artifactStem }}
170191 condition: always()
171192 displayName: Publish Build Log
193+ - ${{ if eq(parameters.enableCaching, true) }}:
194+ - publish: $(Build.SourcesDirectory)\MSBuildCacheLogs
195+ artifact: logs-msbuildcache-$(BuildPlatform)-$(BuildConfiguration)${{ parameters.artifactStem }}
196+ condition: always()
197+ displayName: Publish MSBuildCache Logs
172198 - ${{ else }}:
173199 - task: CopyFiles@2
174200 displayName: Copy Build Log
175201 inputs:
176202 contents: $(Build.SourcesDirectory)/msbuild.binlog
177203 TargetFolder: $(Terminal.BinDir)
204+ - ${{ if eq(parameters.enableCaching, true) }}:
205+ - task: CopyFiles@2
206+ displayName: Copy MSBuildCache Logs
207+ inputs:
208+ contents: $(Build.SourcesDirectory)/MSBuildCacheLogs/**
209+ TargetFolder: $(Terminal.BinDir)/MSBuildCacheLogs
178210
179211 # This saves ~2GiB per architecture. We won't need these later.
180212 # Removes:
0 commit comments