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'
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 ?
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: https://github.com/dotnet/cli/issues/8368#issuecomment-424852996, 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.
Please see this as a workaround.
Created a new issue to handle this problem in Azure pipelines. Closing this issue.
Please see this as a workaround.
@bishal-pdMSFT, I don't know why you closed this. Per my comment above, the work around in (https://github.com/dotnet/cli/issues/8368#issuecomment-424852996) 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.
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.
It's confused situation, we can't use global tools, that well works in Appveyor for example.
according to #8429, the fix is rolled out. @vchirikov do you mean this issue still repros?
@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
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:
````yaml
I'm not sure whether this approach covers any .NET Core tool, but it did the trick for me.
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.
If you're using bash, you could refresh its environment with one or more of the following commands:
. ~/.bashrc
. ~/.bashprofile
. ~/.profile
To fix this I did the following after installing a tool using bash
- script: |
dotnet tool update -g #YOUR TOOL
export PATH=$PATH:$HOME/.dotnet/tools
. ~/.bashrc
# RUN TOOL COMMAND HERE
Most helpful comment
To fix this I did the following after installing a tool using bash