microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.51k stars 2.62k forks source link

[BUG]: UseDotNet - Failed while prepending .Net Core Tool path to PATH envrionment variable. #19368

Open JoaoNeto-TGRE opened 11 months ago

JoaoNeto-TGRE commented 11 months ago

New issue checklist

Task name

UseDotNet

Task version

2.232.0

Issue Description

When installing runtime 8.0.0 using the UseDotNet task I got the following error Failed while prepending .Net Core Tool path to PATH envrionment variable. Error: {"code":"ERR_INVALID_ARG_TYPE"}

I spotted that this line of usedotnet.ts does not run as I cannot see the message in the logs. Scrolling up a bit I noticed the use of path.join that throws the error Invalid Argument when it does not receive a string. From the call here it receives a Constant defined as a path from the utilities file.

Going through Git Blame I did not see any recent changes to any of these files so I don't know if this is the cause of the issue.

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Ubuntu 20.04

Relevant log output

Successfully installed .NET Core runtime version 8.0.0.
Failed while prepending .Net Core Tool path to PATH envrionment variable. Error: {"code":"ERR_INVALID_ARG_TYPE"}

Full task logs with system.debug enabled

 2023-12-12T09:24:28.9177492Z ##[debug]Evaluating condition for step: 'UseDotNet'
2023-12-12T09:24:28.9178430Z ##[debug]Evaluating: SucceededNode()
2023-12-12T09:24:28.9178703Z ##[debug]Evaluating SucceededNode:
2023-12-12T09:24:28.9179149Z ##[debug]=> True
2023-12-12T09:24:28.9179407Z ##[debug]Result: True
2023-12-12T09:24:28.9179759Z ##[section]Starting: UseDotNet
2023-12-12T09:24:28.9189152Z ==============================================================================
2023-12-12T09:24:28.9189415Z Task         : Use .NET Core
2023-12-12T09:24:28.9190296Z 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.
2023-12-12T09:24:28.9191251Z Version      : 2.232.0
2023-12-12T09:24:28.9191390Z Author       : Microsoft Corporation
2023-12-12T09:24:28.9191820Z Help         : https://aka.ms/AA4xgy0
2023-12-12T09:24:28.9191960Z ==============================================================================
2023-12-12T09:24:29.0866095Z ##[debug]Using node path: /myagent/externals/node16/bin/node
2023-12-12T09:24:29.2070720Z ##[debug]agent.TempDirectory=/myagent/_work/_temp
2023-12-12T09:24:29.2085761Z ##[debug]loading inputs and endpoints
2023-12-12T09:24:29.2089272Z ##[debug]loading INPUT_PACKAGETYPE
2023-12-12T09:24:29.2105488Z ##[debug]loading INPUT_USEGLOBALJSON
2023-12-12T09:24:29.2108028Z ##[debug]loading INPUT_WORKINGDIRECTORY
2023-12-12T09:24:29.2111871Z ##[debug]loading INPUT_VERSION
2023-12-12T09:24:29.2112861Z ##[debug]loading INPUT_INCLUDEPREVIEWVERSIONS
2023-12-12T09:24:29.2126115Z ##[debug]loading INPUT_INSTALLATIONPATH
2023-12-12T09:24:29.2127598Z ##[debug]loading INPUT_PERFORMMULTILEVELLOOKUP
2023-12-12T09:24:29.2128425Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2023-12-12T09:24:29.2135137Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2023-12-12T09:24:29.2135936Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2023-12-12T09:24:29.2140663Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2023-12-12T09:24:29.2143729Z ##[debug]loaded 11
2023-12-12T09:24:29.2154304Z ##[debug]Agent.ProxyUrl=undefined
2023-12-12T09:24:29.2155035Z ##[debug]Agent.CAInfo=undefined
2023-12-12T09:24:29.2155722Z ##[debug]Agent.ClientCert=undefined
2023-12-12T09:24:29.2156449Z ##[debug]Agent.SkipCertValidation=undefined
2023-12-12T09:24:29.2533848Z ##[debug]Agent.ProxyUrl=undefined
2023-12-12T09:24:29.2541193Z ##[debug]Agent.CAInfo=undefined
2023-12-12T09:24:29.2546090Z ##[debug]Agent.ClientCert=undefined
2023-12-12T09:24:29.2554871Z ##[debug]check path : /myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/node_modules/azure-pipelines-tool-lib/lib.json
2023-12-12T09:24:29.2565109Z ##[debug]adding resource file: /myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/node_modules/azure-pipelines-tool-lib/lib.json
2023-12-12T09:24:29.2570267Z ##[debug]system.culture=en-US
2023-12-12T09:24:29.2986023Z ##[debug]Setting resource path to /myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/task.json
2023-12-12T09:24:29.2987461Z ##[debug]check path : /myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/task.json
2023-12-12T09:24:29.2988576Z ##[debug]adding resource file: /myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/task.json
2023-12-12T09:24:29.2990100Z ##[debug]system.culture=en-US
2023-12-12T09:24:29.3003723Z ##[debug]check path : /myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/node_modules/azure-pipelines-tasks-packaging-common/module.json
2023-12-12T09:24:29.3005464Z ##[debug]adding resource file: /myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/node_modules/azure-pipelines-tasks-packaging-common/module.json
2023-12-12T09:24:29.3006540Z ##[debug]system.culture=en-US
2023-12-12T09:24:29.3022452Z ##[debug]useGlobalJson=false
2023-12-12T09:24:29.3028928Z ##[debug]packageType=runtime
2023-12-12T09:24:29.3030549Z ##[debug]version=8.x
2023-12-12T09:24:29.3036664Z ##[debug]vsVersion=undefined
2023-12-12T09:24:29.3037324Z ##[debug]nugetVersion=undefined
2023-12-12T09:24:29.3038377Z ##[debug]installationPath=/myagent/_work/_temp/dotnet
2023-12-12T09:24:29.3039319Z ##[debug]performMultiLevelLookup=false
2023-12-12T09:24:29.3044027Z ##[debug]includePreviewVersions=false
2023-12-12T09:24:29.3055691Z ##[debug]workingDirectory=/myagent/_work/3/s
2023-12-12T09:24:29.3060937Z ##[debug]agent.proxyurl=undefined
2023-12-12T09:24:29.3062183Z ##[debug]AZURE_HTTP_USER_AGENT=VSTS_cbf6fa37-7222-465e-ab92-f7b99a972984_build_242_0
2023-12-12T09:24:29.3071743Z ##[debug]testing directory '/myagent/_work/_temp/dotnet'
2023-12-12T09:24:29.3073169Z ##[debug]testing directory '/myagent/_work/_temp'
2023-12-12T09:24:29.3076690Z ##[debug]mkdir '/myagent/_work/_temp/dotnet'
2023-12-12T09:24:29.3095887Z Tool to install: .NET Core runtime version 8.x.
2023-12-12T09:24:29.6607820Z ##[debug]Agent running environment resource - Disk: available:38038.00MB out of 49433.00MB, Memory: used 17MB out of 1921MB, CPU: usage 81.83
2023-12-12T09:24:30.0474006Z ##[debug]Finding channel 8.0 for version 8.x
2023-12-12T09:24:31.5663735Z Found version 8.0.0 in channel 8.0 for user specified version spec: 8.x
2023-12-12T09:24:31.6084360Z ##[debug]Processed: ##vso[telemetry.publish area=TaskDeploymentMethod;feature=UseDotNetV2]{"userVersion":"8.x", "resolvedVersion":"8.0.0"}
2023-12-12T09:24:31.6085206Z get-os-distro: Error: Distribution specific OS name and version could not be detected: UName = Linux
2023-12-12T09:24:31.6085887Z ##[debug]isExplicit: 8.0.0
2023-12-12T09:24:31.6086260Z ##[debug]explicit? true
2023-12-12T09:24:31.6086491Z Version 8.0.0 was not found in cache.
2023-12-12T09:24:31.6086694Z Getting URL to download .NET Core runtime version: 8.0.0.
2023-12-12T09:24:31.6086931Z Detecting OS platform to find correct download package for the OS.
2023-12-12T09:24:31.6087337Z ##[debug]which '/myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/externals/get-os-distro.sh'
2023-12-12T09:24:31.6087816Z ##[debug]found: '/myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/externals/get-os-distro.sh'
2023-12-12T09:24:31.6088297Z ##[debug]which '/myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/externals/get-os-distro.sh'
2023-12-12T09:24:31.6088767Z ##[debug]found: '/myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/externals/get-os-distro.sh'
2023-12-12T09:24:31.6089253Z ##[debug]exec tool: /myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/externals/get-os-distro.sh
2023-12-12T09:24:31.6090016Z ##[debug]arguments:
2023-12-12T09:24:31.6090449Z [command]/myagent/_work/_tasks/UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6/2.232.0/externals/get-os-distro.sh
2023-12-12T09:24:31.6090698Z Primary:linux-x64
2023-12-12T09:24:31.6090851Z Legacy:-x64
2023-12-12T09:24:31.6091024Z Detected platform (Primary): linux-x64
2023-12-12T09:24:31.6091214Z Detected platform (Legacy): -x64
2023-12-12T09:24:31.6091528Z ##[debug]Got download URL for platform with rid: linux-x64
2023-12-12T09:24:31.6092026Z ##[debug]
2023-12-12T09:24:31.6092346Z ##[debug]Agent.Version=3.230.2
2023-12-12T09:24:31.6092705Z ##[debug]Agent.TempDirectory=/myagent/_work/_temp
2023-12-12T09:24:31.6093067Z ##[debug]testing directory '/myagent/_work/_temp'
2023-12-12T09:24:31.6093624Z Downloading: https://download.visualstudio.microsoft.com/download/pr/fc4b4447-45f2-4fd2-899a-77eb1aed7792/6fd52c0c61f064ddc7fe7684e841f491/dotnet-runtime-8.0.0-linux-x64.tar.gz
2023-12-12T09:24:31.6094089Z ##[debug]destination /myagent/_work/_temp/faef75e1-1926-4e05-8f67-acc5ecabd67b
2023-12-12T09:24:31.6094453Z ##[debug]downloading
2023-12-12T09:24:31.6876061Z ##[debug]Content-Length of downloaded file: 31389185
2023-12-12T09:24:31.6877267Z ##[debug]creating stream
2023-12-12T09:24:32.2811575Z ##[debug]download complete
2023-12-12T09:24:32.2818283Z ##[debug]Downloaded file size: 31389185 bytes
2023-12-12T09:24:32.2820308Z Extracting downloaded package /myagent/_work/_temp/faef75e1-1926-4e05-8f67-acc5ecabd67b.
2023-12-12T09:24:32.2823386Z ##[debug]Agent.TempDirectory=/myagent/_work/_temp
2023-12-12T09:24:32.2827134Z Extracting archive
2023-12-12T09:24:32.2829079Z ##[debug]Agent.Version=3.230.2
2023-12-12T09:24:32.2830521Z ##[debug]Agent.TempDirectory=/myagent/_work/_temp
2023-12-12T09:24:32.2834179Z ##[debug]testing directory '/myagent/_work/_temp/5ea83417-74ee-45f1-84d8-01295aff8f21'
2023-12-12T09:24:32.2836312Z ##[debug]testing directory '/myagent/_work/_temp'
2023-12-12T09:24:32.2837587Z ##[debug]mkdir '/myagent/_work/_temp/5ea83417-74ee-45f1-84d8-01295aff8f21'
2023-12-12T09:24:32.2841028Z ##[debug]which 'tar'
2023-12-12T09:24:32.2845028Z ##[debug]found: '/usr/bin/tar'
2023-12-12T09:24:32.2847550Z ##[debug]/usr/bin/tar arg: ["xC","/myagent/_work/_temp/5ea83417-74ee-45f1-84d8-01295aff8f21","-f","/myagent/_work/_temp/faef75e1-1926-4e05-8f67-acc5ecabd67b"]
2023-12-12T09:24:32.2851683Z ##[debug]exec tool: /usr/bin/tar
2023-12-12T09:24:32.2852975Z ##[debug]arguments:
2023-12-12T09:24:32.2853980Z ##[debug]   xC
2023-12-12T09:24:32.2855056Z ##[debug]   /myagent/_work/_temp/5ea83417-74ee-45f1-84d8-01295aff8f21
2023-12-12T09:24:32.2857067Z ##[debug]   -f
2023-12-12T09:24:32.2858025Z ##[debug]   /myagent/_work/_temp/faef75e1-1926-4e05-8f67-acc5ecabd67b
2023-12-12T09:24:32.2859710Z [command]/usr/bin/tar xC /myagent/_work/_temp/5ea83417-74ee-45f1-84d8-01295aff8f21 -f /myagent/_work/_temp/faef75e1-1926-4e05-8f67-acc5ecabd67b
2023-12-12T09:24:33.0361090Z ##[debug]Exit code 0 received from tool '/usr/bin/tar'
2023-12-12T09:24:33.0362057Z ##[debug]STDIO streams have closed for tool '/usr/bin/tar'
2023-12-12T09:24:33.0362881Z ##[debug]Copying all root folders into installation path: /myagent/_work/_temp/dotnet
2023-12-12T09:24:33.1665857Z ##[debug]Creating installation complete marker file for .Net core 8.0.0 version runtime
2023-12-12T09:24:33.1667344Z Successfully installed .NET Core runtime version 8.0.0.
2023-12-12T09:24:33.1675120Z ##[debug]Agent.Version=3.230.2
2023-12-12T09:24:33.1688414Z ##[debug]Processed: ##vso[task.prependpath]/myagent/_work/_temp/dotnet
2023-12-12T09:24:33.1694425Z ##[debug]set DOTNET_ROOT=/myagent/_work/_temp/dotnet
2023-12-12T09:24:33.1699304Z ##[debug]Processed: ##vso[task.setvariable variable=DOTNET_ROOT;isOutput=false;issecret=false;]/myagent/_work/_temp/dotnet
2023-12-12T09:24:33.1700437Z ##[debug]set DOTNET_MULTILEVEL_LOOKUP=0
2023-12-12T09:24:33.1701988Z ##[debug]Processed: ##vso[task.setvariable variable=DOTNET_MULTILEVEL_LOOKUP;isOutput=false;issecret=false;]0
2023-12-12T09:24:33.1702790Z Failed while prepending .Net Core Tool path to PATH envrionment variable. Error: {"code":"ERR_INVALID_ARG_TYPE"}
2023-12-12T09:24:33.1704291Z ##[debug]Agent.ProxyUrl=undefined
2023-12-12T09:24:33.1704921Z ##[debug]task result: Succeeded
2023-12-12T09:24:33.1706819Z ##[debug]Processed: ##vso[task.complete result=Succeeded;]
2023-12-12T09:24:33.1797833Z ##[section]Finishing: UseDotNet 

Repro steps

- task: UseDotNet@2
      inputs:
        packageType: 'runtime'
        version: '8.x'
        installationPath: '$(Agent.TempDirectory)/dotnet'
MrLuje commented 11 months ago

Almost got the same issue with v6.x (but the runner has both 6.x & 8.x versions)

Tool to install: .NET Core sdk version 6.0.x.
Found version 6.0.417 in channel 6.0 for user specified version spec: 6.0.x
Version: 6.0.417 was found in cache.
Failed while prepending .Net Core Tool path to PATH envrionment variable. Error: {}
Finishing: Install .NET 6.0.x SDK

The worst thing on my side is that the task appears as succeed, whereas obviously nothing will work without the DOTNET_CLI_HOME env var

nesherhh commented 6 months ago

Any news on this? I have same error with .NET SDK 8.0.301 and UseDotNet 2.238.1

jkonecki commented 3 months ago

I get the following error when installing 6.x on Ubuntu 22.04.4 LTS:

Tool to install: .NET Core runtime version 6.x.
Found version 6.0.33 in channel 6.0 for user specified version spec: 6.x
Version: 6.0.33 was found in cache.
Failed while prepending .Net Core Tool path to PATH envrionment variable. Error: The "path" argument must be of type string. Received undefined
Finishing: UseDotNet

Debug task output: task-output.txt

Here is the task definition:

- task: UseDotNet@2
  inputs:
    packageType: 'runtime'
    version: '6.x'
AppiePau commented 1 week ago

I have had the same issue with .NET 9.x. Here is the solution:

Have the following config in your yaml pipeline:

- task: UseDotNet@2
  displayName: 'Install .NET Core SDK'
  inputs:
    version: 9.x
    installationPath: '$(Agent.TempDirectory)/dotnet'

Then in the right top corner of your Azure (web) editor click "Variables" and add:

Name: DOTNET_CLI_HOME Value: $(Agent.TempDirectory)/dotnet

That's it!