Stop wasting time during .NET Core builds

Problem:

I am using Hosted build agents to build my ASP.NET Core application and each time they try to cache packages.

Solution:

Set DOTNET_SKIP_FIRST_TIME_EXPERIENCE environment variable to true.

Explanation:

Caching packages on a temporary build machine is a waste of time.  Upon each new build a new machine is provisioned and therefore will not have the cache from before. Each build will report the following status

A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.

To prevent this from happening you need to set an environment variable (DOTNET_SKIP_FIRST_TIME_EXPERIENCE) to true on your build machine.  If you are using containerized builds with Docker simply pass this value in your run command.  If you are using Team Services simply set the value on the variables tab.

image

Comments (14) -

  • Chris Keith

    8/29/2016 1:47:35 AM | Reply

    Useful tip that most of us would not think of. Any idea of how much time can be saved?

    • Donovan

      8/29/2016 2:15:40 AM | Reply

      On a hosted agent 45 to 60 seconds each build.

  • PK

    8/29/2016 3:20:34 AM | Reply

    +1. It will save us time!

    However, the problem with such configurations is that you will never know when they stopped supporting it.

    I would rather prefer a flag that goes along with the dotnet restore command.

    Thanks anyway.

  • Chris Keith

    8/29/2016 5:15:03 AM | Reply

    With ~ 20 packages I see a 12-24 second saving on a hosted build. Still it is something saved. Thanks, would not have found this myself.

    • Donovan

      8/29/2016 2:59:29 PM | Reply

      You might be able to get a little more time by setting NUGET_XMLDOC_MODE=skip.  This will skip xml docs for packages.

  • Mike Jones

    8/29/2016 1:31:32 PM | Reply

    That's a great tip. Could the VSTS hosted build agents automatically default this to true so that we dont have to remember to set this on every build definition?

  • Rui Jarimba

    9/16/2016 7:39:44 AM | Reply

    Hi Donovan,

    Is there any place where I can find more documentation on these environment variables?

    Thanks,
    Rui

    • Donovan

      10/5/2016 8:37:46 PM | Reply

      What specifically are you looking for?  VSTS vars or .NET Core?

  • paul h

    4/21/2017 4:13:19 PM | Reply

    It looks as though this is no longer necessary  - at least on the Hosted VS2017 servers.

    • Alexander Batishchev

      8/17/2019 7:40:31 PM | Reply

      Seems to be necessary still in 2019

  • Niels Swimberghe

    9/14/2019 8:36:12 PM | Reply

    This worked splendidly and reduced the amount of noise in my build logs, thanks.
    For those using YAML, you can use this:
    variables:
      DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

Add comment

Loading