Skip to content

Commit 9b1ebda

Browse files
committed
Cache .NET SDKs and Tools
- Cache everything under '$(Agent.ToolsDirectory)/dotnet' directory to speed up the build. Check for changes in the .NET SDK Version to invalidate and rebuild the cache during subsequent builds.
1 parent 8b13049 commit 9b1ebda

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

azure-pipelines.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,30 @@ pool:
1313

1414
variables:
1515
Build.Configuration: Release
16+
DotNet.Tools: $(Agent.ToolsDirectory)/dotnet
17+
DotNet.Version: 7.0.x
1618

1719
jobs:
1820
- job: BuildBits
1921
displayName: Build and Test solution
2022
timeoutInMinutes: 60
2123
steps:
2224

25+
# Cache .NET SDKs and Tools across pipeline runs
26+
- task: Cache@2
27+
displayName: Cache .NET SDKs
28+
inputs:
29+
key: 'dotnet | "$(Agent.OS)" | "$(DotNet.Version)"'
30+
restoreKeys: |
31+
dotnet | "$(Agent.OS)"
32+
dotnet
33+
path: $(DotNet.Tools)
34+
2335
# Install the .NET 7 SDK
2436
- task: UseDotNet@2
2537
displayName: Install the .NET 7 SDK
2638
inputs:
27-
version: 7.0.x
39+
version: $(DotNet.Version)
2840
includePreviewVersions: true
2941
performMultiLevelLookup: true
3042

0 commit comments

Comments
 (0)