[英]How to pass TestRunParameters to “dotnet test” command directly from command line
[英]How to pass version number from jq for dotnet tool install command in Ubuntu?
这个问题与我之前的问题有关: How to pass a value from JSON to a command in shell script at Docker?
我有一个 shell 脚本文件如下:
name=$(jq '.name' /xxx/deploy-tool.json)
nugetFileVersion=$(jq '.version' /xxx/deploy-tool.json)
#bash
#echo $name
# TODO how to pass value from JSON to the command below
# install dot net nuget
dotnet tool install -g $name --version $nugetFileVersion --add-source /xxx/
这是我的deploy-tool.json
文件
{
"name": "xxx.DEPLOY",
"version": "1.2.0-dev.29"
}
当我在 dockerfile 中运行上面的脚本时,我收到一条错误消息:
指定的版本“1.2.0-dev.29”不是有效的 NuGet 版本范围。
我试图在这里查看dotnet-tool install
文档: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-tool-install但是,我找不到任何有用的东西。
如何将jq
命令中的nugetFileVersion
传递给dotnet tool install
的版本参数,就像我在 powershell 中如何做到这一点一样,如下图所示:
谢谢
当您运行jq.version
时,您会得到 output "1.2.0-dev.29"
。 你需要它没有引号。 为此,请将-r
( --raw-output
) 添加到您的 jq 调用中:
jq -r '.version' yourfile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.