dotnet ef is failing in Azure DevOps Pipeline when the agent is ubuntu-latest
See original GitHub issueBug
I am trying to run dotnet ef command within Azure DevOps Pipeline and it’s failing with the error: Could not execute because the specified command or file was not found.
.
Note: I am installing the tool in the first task and then I am checking the version.
trigger:
- master
resources:
- repo: self
variables:
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: DotNetCoreCLI@2
displayName: Install dotnet-ef
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --global dotnet-ef --version 3.1.1 --ignore-failed-sources'
- task: DotNetCoreCLI@2
displayName: Check dotnet-ef version
inputs:
command: 'custom'
custom: 'ef'
arguments: '--version'
Logs:
Task: Install dotnet-ef
Starting: Install dotnet-ef
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.166.2
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
/usr/bin/dotnet tool install --global dotnet-ef --version 3.1.1 --ignore-failed-sources
Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.101
Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
Since you just installed the .NET Core SDK, you will need to logout or restart your session before running the tool you installed.
You can invoke the tool using the following command: dotnet-ef
Tool 'dotnet-ef' (version '3.1.1') was successfully installed.
Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x SDK/Runtime along with 2.2 & 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions.
Some commonly encountered changes are:
If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
Finishing: Install dotnet-ef
Task: Check dotnet-ef version
Starting: Check dotnet-ef version
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.166.2
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
/usr/bin/dotnet ef --version
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET Core program, but dotnet-ef does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
##[error]Error: The process '/usr/bin/dotnet' failed with exit code 1
Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x SDK/Runtime along with 2.2 & 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions.
Some commonly encountered changes are:
If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[error]Dotnet command failed with non-zero exit code on the following projects :
Finishing: Check dotnet-ef version
However when the agent is windows-2019, it is working.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
dotnet ef is Failing in Azure DevOps Pipeline When the Agent ...
I was trying to run dotnet ef command within Azure DevOps Pipeline and it's failing with the error: Could not execute because the...
Read more >Azure Pipelines - .wapproj Build Fails Using Windows-Latest ...
Today we updated a WPF application from Dot Net Core 3.0 to 3.1. We use Azure Pipelines to test/build it and then deploy...
Read more >Error while installing dotnet-ef in azure pipeline - Stack Overflow
I'm generating ef migration scripts in azure pipelines, for that I'm performing the following tasks: - task: DotNetCoreCLI@2 displayName: ...
Read more >Build, test, and deploy .NET Core apps - Azure Pipelines
Sign-in to your Azure DevOps organization and go to your project. Go to Pipelines, and then select New pipeline. Do the steps of...
Read more >Run EF Core Migrations in Azure DevOps - dotnetthoughts
Create Manifest file - This is again a dotnet command which will help you to create a manifest file using the dotnet new...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@vineetmimrot, Thank you very much for your reply. And extremely sorry for the delay.
And yes, I just tried using
UseDotNet@2
first to install the dotnet sdk and below works.Thanks for the hint on not specifying EF version 👍
Hey @jaliyaudagedara, You should use the UseDotnet@2 task, to install the dotnet sdk (preferably latest version i.e. 3.1.200) and then install the dotnet ef with what you have mentioned in the problem description. This will make dotnet-ef installed into same path as of dotnet sdk and will make it able to execute.
Also as per this issue https://github.com/dotnet/efcore/issues/15448, you should not mention the ef version and let the dotnet tool install the appropriate ef version as per the sdk installed.