Cache .NET 6 in Azure Devops

376 Views Asked by At

I'm facing an issue where the pipeline is unable to retrieve the .NET SDK from the cache but instead downloads it on every build.

I'm currently using a Microsoft-hosted agent in Azure DevOps.

- task: UseDotNet@2
  displayName: 'Get .net core 6'
  inputs:
    packageType: 'sdk'
    version: '6.0.x'
    installationPath: $(Agent.ToolsDirectory)/dotnet

pipelinelogs

Am I missing anything in my yml file?

1

There are 1 best solutions below

2
On

The agent assigned to your build is restored to original state. So even if you install something there and afterward you will get the same agent it would be clear machine.

There is no way to keep something on Microsoft Hosted agents. For that purpose you should use Self hosted agents.