From e91c6091cc019877c196f4324b7931fbfaa2c26f Mon Sep 17 00:00:00 2001 From: Nirmal Guru Date: Sun, 18 Sep 2022 09:10:45 +0530 Subject: [PATCH] Cache .NET SDKs and Tools - Cache everything under '$(Agent.ToolsDirectory)/dotnet' directory to speed up build. Check for changes in .NET SDK Version variable '$(DotNetVersion)' to invalidate and rebuild the cache next build. --- azure-pipelines.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5e1a1aee..902fad7f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,6 +13,8 @@ pool: variables: BuildConfiguration: Release + BuildTools: $(Agent.ToolsDirectory)/dotnet + DotNetVersion: 7.0.x jobs: - job: BuildBits @@ -20,11 +22,21 @@ jobs: timeoutInMinutes: 60 steps: + # Cache .NET SDKs and Tools across pipeline runs + - task: Cache@2 + displayName: Cache .NET SDKs + inputs: + key: 'dotnet | "$(Agent.OS)" | "$(DotNetVersion)"' + restoreKeys: | + dotnet | "$(Agent.OS)" + dotnet + path: $(BuildTools) + # Install the .NET 7 SDK (Fixes dotnet/roslyn#63780) - task: UseDotNet@2 displayName: Install the .NET 7 SDK inputs: - version: 7.0.x + version: $(DotNetVersion) includePreviewVersions: true performMultiLevelLookup: true