Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make dotnet tool restore use ./.config/dotnet-tools.json? #100

Closed
natalie-o-perret opened this issue Jun 21, 2020 · 1 comment
Closed

Comments

@natalie-o-perret
Copy link

natalie-o-perret commented Jun 21, 2020

Description

I have the configuration file (sln-root-folder/.config/dotnet-tools.json) below for .NET tools:

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "dotnet-fsharplint": {
      "version": "0.13.3",
      "commands": [
        "dotnet-fsharplint"
      ]
    }
  }
}

Which works like a charm when restoring the tools:

C:\Users\Michelle\Desktop\Work\sln-root-folder>dotnet tool restore
Tool 'dotnet-fsharplint' (version '0.13.3') was restored. Available commands: dotnet-fsharplint

Restore was successful.
C:\Users\Michelle\Desktop\Work\sln-root-folder>dotnet fsharplint lint --lint-config fsharplint.json MessingUp.sln
========== Linting C:\Users\Michelle\Desktop\Work\sln-root-folder\MessingUp\Library.fs ==========
========== Finished: 0 warnings ==========
========== Linting C:\Users\Michelle\Desktop\Work\sln-root-folder\MessingUp.Tests\Tests.fs ==========
========== Finished: 0 warnings ==========
========== Linting C:\Users\Michelle\Desktop\Work\sln-root-folder\MessingUp.Tests\Program.fs ==========
========== Finished: 0 warnings ==========
========== Summary: 0 warnings ==========

This is fine as long as it is executed on my local machine, whenever I'm doing that in a Github action using setup-dotnet it doesn't work.

Details

Here the code on my GitHub action job:

  lint-code:
    needs: lint-commit
    # So that we don't juggle with different OS for accessing the right path...
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: 2.1
      # For some reasons the path is kinda messed up...
      # Doesn't consider the .config folder =|
      - name: Restore tools
        run: dotnet tool restore
      - name: Run F# Linter
        run: dotnet fsharplint lint --lint-config fsharplint.json MessingUp.sln

Gives the output below:

 Restore tools38s
    DOTNET_ROOT: /opt/hostedtoolcache/dncs/2.1.807/x64

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

Configuring...
--------------
A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.
Decompressing .......... 8081 ms
Expanding .......... 29542 ms

ASP.NET Core
------------
Successfully installed the ASP.NET Core HTTPS Development Certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). For establishing trust on other platforms refer to the platform specific documentation.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
Required command was not provided.
tnet tool [options] [command]

Options:
  -h, --help   Show command line help.

Commands:
  install <PACKAGE_ID>     Install a tool for use on the command line.
  uninstall <PACKAGE_ID>   Uninstall a tool from the current development environment.
  update <PACKAGE_ID>      Update a tool to the latest stable version.
  list                     List tools installed in the current development environment.
##[error]Process completed with exit code 1.

I have a workaround but I would like to avoid defining myself something already available in the ./.config/dotnet-tools.json...

  lint-code:
    needs: lint-commit
    # So that we don't juggle with different OS for accessing the right path...
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: 2.1
      # For some reasons the path is kinda messed up...
      # Doesn't consider the .config folder =|
      - name: Restore tools
        run: |
          export PATH="$PATH:/root/.dotnet/tools"
          dotnet tool install -g dotnet-fsharplint --version 0.13.3
      - name: Run F# Linter
        run: dotnet fsharplint lint --lint-config fsharplint.json MessingUp.sln

How can I just use dotnet tool restore in a GitHub action job where I use setup-dotnet?

@ZEisinger
Copy link
Contributor

For some reason I am having problems using 2.1 for the restore. I had more success with 3.1. But, once it was downloaded the tool itself needs to use 2.1 to run so a Side by Side install was required of 2.1 and some other version. The best way to get this to work right now might just be to remove actions/setup-dotnet (there are a number of preinstalled versions on the github hosted images). Otherwise you can track #25 for getting this to work in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants