dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.71k stars 1.06k forks source link

dotnet restore very slow on Azure pipelines #12445

Open musmuris opened 4 years ago

musmuris commented 4 years ago

This is using an Azure Pipelines hosted agent on windows-latest

Trying out Azure Pipelines on one of our simpler projects and the whole build is taking ~2 mins. However it took 42 seconds just to do the dotnet restore step. In an effort to make this faster I added a cache task but next time, even when the cache restored (in just 7 seconds) it then took 57 seconds to do the restore.

- task: Cache@2
  inputs:
    key: 'nuget | "$(Agent.OS)" | **/*.csproj'
    restoreKeys: |
       nuget | "$(Agent.OS)"
       nuget
    path: $(Pipeline.Workspace)/.nuget/packages
  displayName: Cache NuGet packages

- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore
    projects: $(solution)
    feedsToUse: 'select'
    verbosityRestore: 'Normal'

It can also massively vary between builds - I have seen one with just 20s but also one at 72s (it's around 40-50 usually). By contrast if I clean my local repo and try it then it's <10s to complete.

Task log files cachedrestore.txt nocacherestore.txt

MeTitus commented 2 years ago

Why was this closed? It's still very slow. Could it be because MS is trying to earn a few more bucks here?

jinweili1 commented 1 year ago

Hi team, we met the same problem as this, does anyone know what caused it? We pre-installed 1000 packages in global nuget package cache folder, and the runtime of restore task sometimes increase and hang on Checking compatibility of packages.