【问题标题】:Github Action- How to restart the session?Github Action- 如何重启会话?
【发布时间】:2020-03-19 12:12:27
【问题描述】:

我有一个 Github Action,它创建了一个 dotnet tool,并尝试使用它。

$ dotnet pack MyTool.csproj --configuration Release
$ dotnet tool install --global --add-source . MyTool

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: my-tool
Tool 'MyTool' (version '1.0.0') was successfully installed.

$ my-tool

my-tool: command not found

我怎样才能在工作中logout or restart my session,重新加载PATH

【问题讨论】:

    标签: ubuntu github-actions dotnet-tool


    【解决方案1】:

    在名为Install a global tool 的部分中,它说这些工具安装在以下位置:

    OS Path
    Linux/macOS $HOME/.dotnet/tools
    Windows %USERPROFILE%\.dotnet\tools

    下面还写着:

    此位置在 SDK 首次运行时添加到用户的路径中, 因此可以从任何目录调用全局工具而无需指定 工具位置。

    但是,从您的输出看来,您还刚刚安装了 .NET SDK,因此它没有机会将这些文件夹添加到 PATH

    立即想到有两种方法:

    1. 既然你已经知道工具的安装位置,那么就使用你刚刚安装的工具的绝对路径:$HOME/.dotnet/tools/my-tool

    2. 另一种方法是在运行该工具之前修复PATH,以便在您执行安装该工具的步骤时,它已经可用。在您的工作流程中,有很多方法可以修改 PATH,但最简单的方法似乎是修改 $GITHUB_PATH 文件。所以在上一步中,在run中执行以下操作

      run:
         ...
         mkdir --parents $HOME/.dotnet/tools
         echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
      

    完成后,下一步,安装后应该可以访问该工具了。

    【讨论】:

      猜你喜欢
      • 2017-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-24
      • 2020-04-11
      • 2012-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多