Unable to run custom dotnet command as TeamCity build step


Current setup: Server Running Ubuntu 18 TeamCity Professional 2019.2 (build 71499)

I'm working on setting up a build task to generate SQL migration scripts using the following command

dotnet ef migrations script --output "script.sql" --context MyContext

However, when running the project build on TeamCity when this build step is reached the build fails with the following error.

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.
  Process exited with code 1
  Process exited with code 1 (Step: Generate SQL Script (Command Line))
  Step Generate SQL Script (Command Line) failed

If I run the command via the ubuntu shell on the TeamCity server it runs without issue but when running it via TeamCity itself I get the above error message. Do I need to tell TeamCity where dotnet is installed? If so where?

The build step is setup as follows:

Runner Type: Command Line

Run: Custom script

Custom scriptdotnet ef migrations script --output "script.sql" --context MyContext

1 comment
Comment actions Permalink

The script will need to run on the Build Agent Server, which may not be the TeamCity Server. Is your Build Agent on the same server as your TeamCity installation?

You may need to specify the path to dotnet if the location is not present in PATH for the user running the Build Agent, since it is being run in a command prompt. 


Please sign in to leave a comment.