I'm trying to create an Entity Framework Migration script from my Azure Build Pipe Line.
I have the following two steps. The first step installs version 3.0.0 of dotnet-ef (I'm using .NET Core 3.0). The second step tries to generate the script which is failing and I can't work out why. It seems to work when the Agent Specification is set to "windows-2019" but not "ubuntu-18.04". Does anyone know why this may be the case?
============================================================================== Task : .NET Core Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command Version : 2.158.1 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.0.0 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.0.0') was successfully installed. Finishing: dotnet-ef tool install
============================================================================== Task : .NET Core Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command Version : 2.158.1 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli ============================================================================== /usr/bin/dotnet ef migrations script --idempotent --project /home/vsts/work/1/s/blah1.csproj --startup-project /home/vsts/work/1/s/blah2.csproj --output /home/vsts/work/1/a/migrations/BlahContext.sql --context BlahContext 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 ##[error]Dotnet command failed with non-zero exit code on the following projects : Finishing: Generate RnhContext Migration Scripts
How to create Entity Framework Migration script from Azure Build Pipe Line?
I could reproduce this issue on agent
ubuntu-18.04 with command line task.
Since I am not familiar with the dotnet ef migration script, I use the command line
dotnet ef instead. Now, I got the same issue:
After a period of investigation, I found I need add a line to your shell's configuration before I execute the command
So, my command line looks like:
As test, it works fine on the agent
Check the related ticket for some more details.
Hope this helps.