【问题标题】:Unable to run custom dotnet command as TeamCity build step无法将自定义 dotnet 命令作为 TeamCity 构建步骤运行
【发布时间】:2021-07-23 20:39:33
【问题描述】:

当前设置:

  • 运行 Ubuntu 18 的服务器
  • TeamCity Professional 2019.2(内部版本 71499)

我正在设置构建任务以使用以下命令生成 SQL 迁移脚本:

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

但是,在 TeamCity 上运行构建时,构建失败并出现以下错误:

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

如果我通过 TeamCity 服务器上的 Ubuntu shell 运行该命令,它运行没有问题,但是当通过 TeamCity 本身运行它时,我会收到上述错误消息。我需要告诉 TeamCity dotnet 的安装位置吗?如果是在哪里?

构建步骤设置如下:

运行器类型:命令行

运行:自定义脚本

自定义脚本dotnet ef migrations script --output "script.sql" --context MyContext

【问题讨论】:

  • 即使我得到相同的结果?还没有答案吗?太可怕了!

标签: .net teamcity entity-framework-migrations


【解决方案1】:

TeamCity 现在支持使用他们的 .NET 运行程序运行自定义 "dotnet" 命令,但是,他们的文档不是特别清楚。您无需为 "Executables" 字段指定任何值,因为假定为 "dotnet",而是将所有附加参数放入 "Command行参数”字段如下图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-23
    • 1970-01-01
    • 2017-03-09
    • 1970-01-01
    • 1970-01-01
    • 2012-07-22
    • 1970-01-01
    • 2020-07-07
    相关资源
    最近更新 更多