8
votes

I have asp.net core 2.0 app, which references Microsoft.AspNetCore.All metadata package

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />

and I have following build in VSTS which I build using hosted build agent.

Why it always takes min 95 seconds to restore the packages? I thought that

  1. Microsoft.AspNetCore.All packages are cached in ".NET Core runtime store" so they don't have to be restored.
  2. When I restore the packages once, they don't have to be be restored again in every build, since they are cached.

enter image description here

Why is dotnet restore so slow in VSTS?

Edit: Vote for better VSTS build performance here: https://visualstudio.uservoice.com/forums/330519-visual-studio-team-services/suggestions/32044321-improve-hosted-build-agent-performance

3
Are you using the hosted agent or a private agent? The hosted agent is always from a fresh VM and thus has no caching occurring.Daniel Mann
As usual, the answer is to throw money at the problem. The hosted build agents are nice in that they don't require any config and are provided free of charge. However, if build times are critical, then you should look into creating your own dedicated build server that you can make as beastly as you want (or can afford). Otherwise, take what you get and be happy.Chris Pratt
@DanielMann: hosted agent as I mentioned.Liero
@ChrisPratt: money is not a problem. Time is the problem and dedicated build server that I have to manage is waste of time. I have no problem paying for services as long as they will save me time.Liero
I guess the better question would be, why isn't common stuff like "Microsoft.AspNetCore.All" cached? This should be pretty common. This is starting to take several minutes to restore. By caching this, it should actually reduce the VM cost load internally for the VSTS team.Tim P.

3 Answers

4
votes

From the Microsoft Docs on Hosted Agents:

Capabilities and limitations

Hosted agents:

  • Run as a service.
  • Have the above software. You can also add software using our tool installers.
  • Provide 10GB of storage.

Hosted agents do not offer:

  • Interactive mode.
  • Administrator privileges.
  • The ability to log on.
  • The ability to drop artifacts to a UNC file share.
  • The ability to run XAML builds.
  • Potential performance advantages that you might get by using private agents which might start and process builds faster. Learn more

If our hosted agents don't meet your needs, then you can deploy your own private agents.

Long and short, using the hosted agents, what you get is what you get. If it's not fast enough for you or doesn't do something else you'd like (such as caching of NuGet packages), then your recourse is to create your own private build agent.

3
votes

The download of NuGet packages itself is fast, after it actually starts that is.

If you look in the logs the task spends around 1 minute (varies a bit at each build) doing nothing.

From one my last logs, 50 seconds doing nothing:

...
2018-02-04T09:51:47.1349027Z [command]d:\a\_tool\NuGet\4.3.0\x64\nuget.exe restore d:\a\1\s\MySolution.sln -Verbosity Detailed -NonInteractive -ConfigFile d:\a\1\Nuget\tempNuGet_84.config
2018-02-04T09:52:37.2580691Z NuGet Version: 4.3.0.4406
...
3
votes

Try use a solution file instead of **/*.csproj. For me, while restoring **/*.csproj took around 2 mins, restoring the solution file only took 10 seconds.