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
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)
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 3 years ago
- Reactions: 4
- Comments: 17
Commits related to this issue
- Fixes isVersionInstalled for hosted build agent #15020 UseDotNet@2 always downloads SDK, even when it is already installed, because it checks for {version}.complete file which is not present in SDK/r... — committed to Liero/azure-pipelines-tasks by Liero 6 months ago
- Fixes UseDotNet@2 always downloads SDK, even when it is already installed #15020 — committed to Liero/azure-pipelines-tasks by Liero 6 months ago
- Remove UseDotNet@2 task and use runtime/sdk from the host instead See https://github.com/microsoft/azure-pipelines-tasks/issues/15020 — committed to sql-bi/Bravo by albertospelta 2 months ago
- Revert #778, fixup downgrade runtime on self-contained publish (#789) * Revert "Enable TargetLatestRuntimePatch in csproj (#788)" This reverts commit a29152c47c77e7ea8543004e1a4081d33f9b659c. *... — committed to sql-bi/Bravo by albertospelta 2 months ago
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.
Stale? Really? How is this getting marked as stale when the assignee has not bothered to comment?
I’ve created PR that should fix this. Can you review it please?
The cynic in me thinks that not fixing this may be creating a few thousand hours of billable compute time.
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.
The claim that this task uses the tool cache is a lie - it doesn’t work.
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 defaultThe hosted agents do not create a
.complete
file, which is what the task actually looks for to verify if the version is in the cacheEven 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 usedThe task will report
Version: 3.1.411 was found in cache.
but the PATH and DOTNET_ROOT are updated withC:\Program Files\dotnet
or/usr/share/dotnet
which is not where the cached version is installed#13107