Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After executing `dotnet tool install` command in a yml script for DevOps Pipelines, the installed tool is not found? #8291

Closed
StefH opened this Issue Sep 12, 2018 · 10 comments

Comments

Projects
None yet
7 participants
@StefH
Copy link

commented Sep 12, 2018

Environment

  • Server : Online Azure DevOps Pipelines

YML script

pool:
  vmImage: 'vs2017-win2016'
  
variables:
  buildConfiguration: 'Release'

steps:
- script: |
    dotnet tool install --global dotnet-sonarscanner
    dotnet sonarscanner begin /k:"***" /d:sonar.organization="***" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="%SONAR_TOKEN%" /v:"%BUILD_ID%"
    dotnet build ./src/***.csproj --configuration $(buildConfiguration)
    dotnet build ./test/***.csproj --configuration $(buildConfiguration)
    dotnet test ./test/***.csproj --configuration $(buildConfiguration) --framework net452 --logger trx --collect:"Code Coverage"
    dotnet sonarscanner end /d:sonar.login="%SONAR_TOKEN%"

- task: PublishTestResults@2
  inputs:
    testRunner: VSTest
    testResultsFiles: '**/*.trx'

Issue Description

I get an error when using dotnet tool install --global *** in the new Azure Pipelines flow.

My command is like (see above YML file):

dotnet tool install --global dotnet-sonarscanner

This command outputs this:

Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed.
You can invoke the tool using the following command: dotnet-sonarscanner
Tool 'dotnet-sonarscanner' (version '4.3.1') was successfully installed.

And the next step will fail (running the above command in the same step or a different script step make no difference)

No executable found matching command "dotnet-sonarscanner"

How to solve this ?

@cosmoKenney

This comment has been minimized.

Copy link

commented Sep 26, 2018

I have the same problem. I am using a dotnet tool install for dotnet-xdt in one step. That succeeds. Then in a dotnet publish step, dotnet-xdt is executed via the csproj file. But the dotnet-xdt tool cannot be found.

I've tried to switch to a CMD step to do the dotnet tool install as per this issue: dotnet/cli#8368 (comment), but it still does not work for me.

Last time I worked on this project was 8/20/18. And the unchanged pipeline worked then. But today it is no longer working and I haven't changed the csproj or the build pipeline.

@bishal-pdMSFT

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2018

Please see this as a workaround.

@bishal-pdMSFT

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2018

Created a new issue to handle this problem in Azure pipelines. Closing this issue.

@cosmoKenney

This comment has been minimized.

Copy link

commented Sep 27, 2018

Please see this as a workaround.

@bishal-pdMSFT, I don't know why you closed this. Per my comment above, the work around in (dotnet/cli#8368 (comment)) doesn't work for all global tools. I found that if you install a global tool in one pipeline step, then use it in another step, the tool will have been installed in some directory that the build is not happening in. So the tool still cannot be found.

@bishal-pdMSFT

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2018

I have created a new issue for this. #8429
Created a new issue as that is applicable only when Dotnet core tool installer task in used. Azure pipelines cannot fix the scenario when an existing installation of dotnet is used - that has to be fixed by dotnet team.

@vchirikov

This comment has been minimized.

Copy link

commented Oct 22, 2018

It's confused situation, we can't use global tools, that well works in Appveyor for example.

@wli3

This comment has been minimized.

Copy link
Contributor

commented Oct 22, 2018

according to #8429, the fix is rolled out. @vchirikov do you mean this issue still repros?

@vchirikov

This comment has been minimized.

Copy link

commented Oct 22, 2018

@wli3 Yes, yesterday I got this error.
I installed dotnet tool install -g Cake.Tool successfully, but in next step I do something like dotnet cake build/build.cake --target=Coverage and command failed with No executable found matching command "dotnet-cake"
p.s. I don't like your task for install something, just use script

satrapu added a commit to satrapu/aspnet-core-logging that referenced this issue Nov 25, 2018

Added task to install specific .NET Core SDK as this should fix the i…
…ssue of installing a global tool which is then not found by following tasks.

See more here: Microsoft/azure-pipelines-tasks#8291 (comment).
@satrapu

This comment has been minimized.

Copy link

commented Nov 25, 2018

I wanted to use both ReportGenerator and SonarScanner in my Azure DevOps pipeline and of course, I have encountered the infamous error "No executable found matching command ...".
Th only way I managed to install and use both of these tools was by installing a specific .NET Core SDK version via the DotNetCoreInstaller@0 task before hand:

- task: DotNetCoreInstaller@0
  displayName: Install .NET Core SDK
  name: install_dotnetcore_sdk
  enabled: true
  inputs:
    packageType: 'sdk'
    version: '2.1.500'

I'm not sure whether this approach covers any .NET Core tool, but it did the trick for me.

@wli3

This comment has been minimized.

Copy link
Contributor

commented Nov 26, 2018

I think the reason is only DotNetCoreInstaller@0 task will export the global tools path to PATH. And I do think putting extra in PATH by default need more discussion. Meanwhile you could export $HOME/.dotnet/tools or %USERPROFILE%\.dotnet\tools to PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.