azure-pipelines-tasks: [BUG] UseDotNet@2 always downloads SDK, even when it is already installed

Question, Bug, or Feature?
Type: BUG

Enter Task Name: Use .NET core v2

Environment

  • Server - Azure Pipelines or TFS on-premises? Azure pipeline

    • If using Azure Pipelines, provide the account name, team project name, build definition name/build number: Not posting private information to a public place. You shouldnt really be asking us to divulge that.

Issue Description

In the WIndows 2019 hosted agent image inventory, it lists the versions of the .net core SDK that are available, including 3.1.410 image

In the build pipeline, there is a Use .NET Core v2 task that is configured to use .net 3.x (we are skipping .net5 and will look to target 6 when its released) image

When the pipeline runs, it determines it needs to use version 3.1.410 as it is the latest version that matches the configured spec. Since this version is also already installed on the agent already, I would expect that this installation is what is used. However, per the task logs the pipeline downloads and installs this SDK version. This task takes about 60 seconds to complete, when it should take less time as it should not need to download and install anything.

Starting: Use .NET Core sdk 3.x
==============================================================================
Task         : Use .NET Core
Description  : Acquires a specific version of the .NET Core SDK from the internet or the local cache and adds it to the PATH. Use this task to change the version of .NET Core used in subsequent tasks. Additionally provides proxy support.
Version      : 2.184.0
Author       : Microsoft Corporation
Help         : https://aka.ms/AA4xgy0
==============================================================================
Tool to install: .NET Core sdk version 3.x.
Found version 3.1.410 in channel 3.1 for user specified version spec: 3.x
Version 3.1.410 was not found in cache.
Getting URL to download .NET Core sdk version: 3.1.410.
Detecting OS platform to find correct download package for the OS.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& 'D:\a\_tasks\UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6\2.184.0\externals\get-os-platform.ps1'"
Primary:win-x64
Detected platform (Primary): win-x64
Downloading: https://download.visualstudio.microsoft.com/download/pr/94cd3943-95b4-4d86-a3ec-07f434b460b9/e0db650eba4bf8b3ec8ef99312a66047/dotnet-sdk-3.1.410-win-x64.zip
Extracting downloaded package D:\a\_temp\d16cf416-68be-4acb-92d1-cf4c4f49cf40.
Extracting archive
C:\Windows\system32\chcp.com 65001
Active code page: 65001
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('D:\a\_temp\d16cf416-68be-4acb-92d1-cf4c4f49cf40', 'D:\a\_temp\a9e3')"
Successfully installed .NET Core sdk version 3.1.410.
Creating global tool path and pre-pending to PATH.
Finishing: Use .NET Core sdk 3.x

Is the agent installation manifest correct and this task is bugged, or is the agent installation manifest incorrect?

I realize this bug is a money maker for you (because by not fixing this, builds take longer, which increases the number of concurrent hosted agents that we have to pay for just to keep up), but its not working as advertised.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 8
  • Comments: 28

Commits related to this issue

Most upvoted comments

A bit surprising that this ticket is going on 3 years old considering it’s just bad pathing causing a cache miss for everyone using .NET builds on hosted Windows agents.

The cynic in me thinks that not fixing this may be creating a few thousand hours of billable compute time.

Stale? Really? How is this getting marked as stale when the assignee has not bothered to comment?

@bishal-pdMSFT / @chshrikh / @v-bsanthanak can you comment on this, please? the community has provided a fix for this, it’s assigned to you and there’s been no action taken. If not you, please help direct this to someone who can see this through to resolution.

What actions are necessary to see this completed? Who would review the PR provided? What additional code changes are required?

Can we get a status update to this ticket? Looks like there is a PR that will address this that has been sitting open for review.

A bit surprising that this ticket is going on 3 years old considering it’s just bad pathing causing a cache miss for everyone using .NET builds on hosted Windows agents.

Any progress on this issue?

It adds a lot of wasted resources, both bandwidth and cpu cycles.

@bishal-pdMSFT / @chshrikh / @v-bsanthanak can you comment on this, please? the community has provided a fix for this, it’s assigned to you and there’s been no action taken. If not you, please help direct this to someone who can see this through to resolution.

What actions are necessary to see this completed? Who would review the PR provided? What additional code changes are required?

Microsoft, I am going to continue to mention people in this issue, especially anyone who has touched this task until you look at this.

@ivanduplenskikh / @KonstantinTyukalov / @aleksandrlevochkin / @DmitriiBobreshev / @DenisRumyantsev / @max-zaytsev / @cwall-dev / @merlynomsft / @EshitaD / @v-mohithgc

For those of you being added to the chat, please look at the PR. Tell us how to proceed.

I’ve created PR that should fix this. Can you review it please?

We are also waiting for a fix to this.

hey everybody, lets ping this issue so that it at least annoys the maintainer, if there are any left. IMO I guess azure pipelines are destined for extinction and Microsoft will move to githyb actions and won’t invest in in anymore

Please fix this. UseDotNet takes a minute on Windows, which is unnecessary if the version exists on the build agent. This works fine on Ubuntu, where it only takes a few seconds.

bump

The claim that this task uses the tool cache is a lie - it doesn’t work.

  1. The hosted agents install dotnet into C:\Program Files\dotnet\sdk or /usr/share/dotnet/sdk - these directories are not part of the Agent.ToolsDirectory which is where the task looks by default

  2. The hosted agents do not create a .complete file, which is what the task actually looks for to verify if the version is in the cache

  3. Even if you set the installationPath and create the .complete file, the task will report that it has found the version in the cache, but then it incorrectly sets DOTNET_ROOT, so the cached version is not used

parameters:
  - name: dotnet_version
    type: string
    default: 3.1.411

variables:
  - name: System.Debug
    value: true

jobs:
  - job: job1
    dependsOn: []
    pool:
      vmImage: windows-latest
    steps:
      - checkout: none
      - pwsh: |
          get-item 'C:\Program Files\dotnet\sdk\${{ parameters.dotnet_version }}'
          new-item 'C:\Program Files\dotnet\sdk\${{ parameters.dotnet_version }}.complete'
      - task: UseDotNet@2
        displayName: use dot net
        inputs:
          version: ${{ parameters.dotnet_version }}
          installationPath: C:\Program Files\dotnet
      - pwsh: |
          $env:DOTNET_ROOT
          gci $env:DOTNET_ROOT
          dotnet --version
  - job: job2
    dependsOn: []
    pool:
      vmImage: ubuntu-latest
    steps:
      - checkout: none
      - pwsh: |
          get-item /usr/share/dotnet/sdk/${{ parameters.dotnet_version }}
          & sudo touch /usr/share/dotnet/sdk/${{ parameters.dotnet_version }}.complete
      - task: UseDotNet@2
        displayName: use dot net
        inputs:
          version: ${{ parameters.dotnet_version }}
          installationPath: /usr/share/dotnet
      - pwsh: |
          $env:DOTNET_ROOT
          gci $env:DOTNET_ROOT
          dotnet --version

The task will report Version: 3.1.411 was found in cache. but the PATH and DOTNET_ROOT are updated with C:\Program Files\dotnet or /usr/share/dotnet which is not where the cached version is installed

#13107