【问题标题】:Where is the dotnet runtime installed to on Ubuntu?Ubuntu 上的 dotnet 运行时安装在哪里?
【发布时间】:2018-01-13 09:43:29
【问题描述】:

我正在尝试将 dotnet (.NET Core) 与 cron 作业一起使用,但似乎 dotnet 的路径变量在 cron 范围内不存在。我想添加 cron 的路径,但我需要知道 dotnet 从典型的 Ubuntu 安装中实际安装到的位置。还知道如何将路径变量添加到 cron 也会有所帮助,但我想我可以在拥有 dotnet 安装目录后弄清楚。

【问题讨论】:

    标签: ubuntu cron .net-core


    【解决方案1】:

    默认情况下,.NET Core(“dotnet”)安装到 /usr/share/dotnet/

    据我所知,不能为 cron 永久设置路径环境变量,但可以通过在需要该变量的部分之前将脚本添加到 crontab 文件中来临时设置(请参阅here

    或者,您可以在 crontab 中指定 dotnet 的绝对路径,即/usr/share/dotnet/dotnet run --project /path/to/csproj/

    【讨论】:

    • 我的是 usr/bin/dotnet
    【解决方案2】:

    在看到 Gomes 的评论后,我检查了一下,似乎两者在我的系统中都是有效的:

    $ /usr/bin/dotnet --version
    2.1.400
    $ /usr/share/dotnet/dotnet --version
    2.1.400
    

    我做了更多研究,似乎在许多 unix 方言中找到这个的常用方法(根据 https://kb.iu.edu/d/acec)是借助 whereis 命令:

    $ whereis dotnet
    dotnet: /usr/bin/dotnet /usr/share/dotnet /usr/share/man/man1/dotnet.1.gz
    

    但经过进一步审查,我可以看到 /usr/bin/dotnet 只是指向 /share/dotnet/dotnet 的符号链接:

    /usr/bin$ ll dotnet
    lrwxrwxrwx 1 root root 22 Jun 29 17:48 dotnet -> ../share/dotnet/dotnet*
    

    该页面还显示了如何在运行您在终端中键入的命令which command时查看操作系统使用的是哪一个:

    $ which dotnet
    /usr/bin/dotnet
    

    【讨论】:

    • 如果您使用 snap 进行安装(根据 microsoft 文档),请使用 whereis dotnet 获取正确的安装路径。
    猜你喜欢
    • 2011-11-04
    • 2011-07-15
    • 2021-12-10
    • 2014-09-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多