microsoft / azure-pipelines-tasks

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

DotNetCoreCLI's arguments does not expand ~ to home directory #10731

Closed wli3 closed 3 years ago

wli3 commented 5 years ago

relate to https://github.com/dotnet/cli/issues/11603 cc @vinnytheviking

Note

Issues in this repo are for tracking bugs, feature requests and questions for the tasks in this repo

For a list:
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

If you have an issue or request for the Azure Pipelines service, use developer community instead:

https://developercommunity.visualstudio.com/spaces/21/index.html )

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: DotNetCoreCLIV2 list here (V# not needed):
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

Environment

Issue Description

~ will not expend as the following

steps:
- task: DotNetCoreCLI@2
  displayName: 'Install Stryker'
  continueOnError: true
  inputs:
    command: custom
    custom: tool
    arguments: 'install dotnet-stryker --tool-path ~/tools'

- script: |    
    ls ~/tools # will fail as no such folder since ~ is not expand. More see log
  displayName: 'ls 

it works in local ubuntu. I think arguments: 'install dotnet-stryker --tool-path ~/tools' does not expand as normal shell

Task logs

[Enable debug logging and please provide the zip file containing all the logs for a speedy resolution]

Troubleshooting

Checkout how to troubleshoot failures and collect debug logs: https://docs.microsoft.com/en-us/vsts/build-release/actions/troubleshooting

Error logs

.......
.......
2019-06-21T21:26:18.0962155Z HEAD is now at 4cceeab Update azure-pipelines.yml for Azure Pipelines
2019-06-21T21:26:18.1036840Z ##[section]Finishing: Checkout
2019-06-21T21:26:18.1054257Z ##[section]Starting: Install Stryker
2019-06-21T21:26:18.1059072Z ==============================================================================
2019-06-21T21:26:18.1059279Z Task         : .NET Core
2019-06-21T21:26:18.1059313Z Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
2019-06-21T21:26:18.1059347Z Version      : 2.153.0
2019-06-21T21:26:18.1059387Z Author       : Microsoft Corporation
2019-06-21T21:26:18.1059421Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
2019-06-21T21:26:18.1059454Z ==============================================================================
2019-06-21T21:26:20.7703719Z [command]/usr/bin/dotnet tool install dotnet-stryker --tool-path ~/tools
2019-06-21T21:26:31.1144402Z You can invoke the tool using the following command: dotnet-stryker
2019-06-21T21:26:31.1186259Z Tool 'dotnet-stryker' (version '0.11.0') was successfully installed.
2019-06-21T21:26:31.1412390Z ##[section]Finishing: Install Stryker
2019-06-21T21:26:31.1418256Z ##[section]Starting: ls
2019-06-21T21:26:31.1420444Z ==============================================================================
2019-06-21T21:26:31.1420557Z Task         : Command line
2019-06-21T21:26:31.1420590Z Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2019-06-21T21:26:31.1420622Z Version      : 2.151.1
2019-06-21T21:26:31.1420695Z Author       : Microsoft Corporation
2019-06-21T21:26:31.1421144Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2019-06-21T21:26:31.1421182Z ==============================================================================
2019-06-21T21:26:31.2718700Z Generating script.
2019-06-21T21:26:31.2767313Z Script contents:
2019-06-21T21:26:31.2767399Z ls ~/tools
2019-06-21T21:26:31.2767437Z ========================== Starting Command Output ===========================
2019-06-21T21:26:31.2774952Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/863553a7-abae-4e27-bc4e-a3a4c99b423a.sh
2019-06-21T21:26:31.2845787Z ls: cannot access '/home/vsts/tools': No such file or directory
2019-06-21T21:26:31.2976586Z ##[error]Bash exited with code '2'.
2019-06-21T21:26:31.3008899Z ##[section]Finishing: ls
2019-06-21T21:26:31.3022466Z ##[section]Starting: Checkout
2019-06-21T21:26:31.3024302Z ==============================================================================
2019-06-21T21:26:31.3024345Z Task         : Get sources
2019-06-21T21:26:31.3044198Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2019-06-21T21:26:31.3044264Z Version      : 1.0.0
2019-06-21T21:26:31.3044301Z Author       : Microsoft
2019-06-21T21:26:31.3044387Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2019-06-21T21:26:31.3044423Z ==============================================================================
2019-06-21T21:26:31.7324454Z Cleaning any cached credential from repository: msbuildsdksample (Git)
2019-06-21T21:26:31.7368201Z ##[section]Finishing: Checkout
2019-06-21T21:26:31.7436107Z ##[section]Starting: Finalize Job
2019-06-21T21:26:31.7478684Z Start cleaning up orphan processes.
2019-06-21T21:26:31.7560439Z ##[section]Finishing: Finalize Job
2019-06-21T21:26:31.7617495Z ##[section]Finishing: Job
vineetmimrot commented 5 years ago

Thanks @wli3 for reporting the issue , I will have a look and get back to you asap.

vineetmimrot commented 5 years ago

@wli3 We are directly passing the arguments to dotnet tool, and it is instaling the tool into \<WorkingDirectory>/~/tools folder where \<WorkingDirectory> is input field in the task. I think dotnet is not able to expand ~ internally.

vineetmimrot commented 5 years ago

@wli3 One more thing, in the error logs you have pasted, it shows everything is working fine and also it mentions "./tools" instead of "~/tools". Can you double check your yaml script for this scenario.

wli3 commented 5 years ago

Sorry. I pasted the wrong log. I updated it to the right log in ~

wli3 commented 5 years ago

I think dotnet is not able to expand ~ internally.

(FYI I am on the dotnet team) if you run the same command on a normal ubuntu machine, it can work -- it is the bash shell that is expending it. However, the Task does not. I do understand the technical reason. However, this discrepancy between shell experience and the Task will trick the user to the error. Maybe you could always let it pass through bash first. Or expend it, and treat all the "argument" as a special shell. Or at least you could have some documentation for this behavior(or warning in UI). It is not easy to debug it when it happens.

Also $HOME will not expand as well

vineetmimrot commented 5 years ago

Hey @wli3 , We are exploring ways to handle this scenario as this is the first time one has asked about this scenario and this change may break other people's scenario. Anyhow the Cx is unblocked by using Agent.BuildDirectory.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open for a year with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days