dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.66k stars 1.06k forks source link

Make 'dotnet tool restore' Automatic #4241

Open RehanSaeed opened 4 years ago

RehanSaeed commented 4 years ago

Before I run a tool (e.g. dotnet cake) from my dotnet tool manifest file (shown below), I have to remember to run dotnet tool restore first.

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "cake.tool": {
      "version": "0.36.0",
      "commands": [
        "dotnet-cake"
      ]
    }
  }
}

Similar to how dotnet build now automatically runs dotnet restore for you, can running dotnet cake also run dotnet tool restore for me?

theprash commented 4 years ago

This feels like a simple but effective usability improvement since dotnet already knows that a restore is needed: Run "dotnet tool restore" to make the "fake" command available.

It would allow us to remove what feels like an unnecessary extra instruction for users of the SAFE Template.

Tyrrrz commented 4 years ago

I agree. It would allow me to remove this code from every project:

https://github.com/Tyrrrz/LightBulb/blob/06f53a3f37e37e6616e158fbc1b0d63ff6c69845/LightBulb/LightBulb.csproj#L32

640774n6 commented 4 years ago

Probably not worth looking into if this is made automatic, but I can't seem to get "dotnet tool restore" to work if run from from an ExecTask as mentioned above. Using VS for mac and the following:

<Target Name="Restore Local Tools" AfterTargets="BeforeBuild">
  <Exec Command="dotnet tool restore" />
</Target>

Building results with:

Error: Unable to get repository signature information for source https://api.nuget.org/v3-index/repository-signatures/5.0.0/index.json. 

Error: Could not load file or assembly 'System.Security.Permissions, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

It works as expected if I run "dotnet build" on the csproj from a terminal. Anyone seen anything like this before?

Sennevds commented 4 years ago

+1 this is very annoying that it doesn't do this automatically

wooferclaw commented 2 years ago

please add support for this feature

MartinAmaral commented 11 months ago

If the directory where you put your project has special characters you are going to have an error when doing the dotnet commands

Meligy commented 11 months ago

If the directory where you put your project has special characters you are going to have an error when doing the dotnet commands

@MartinAmaral that's probably true. @IslamMeligy fact an issue with running a dotnet application one and then discovered that on this machine the source code was nested under a folder that started with #, which was valid for Windows, but was a problem for dotnet.

However, this is probably another issue separate from the one we are commenting on.

baronfel commented 6 months ago

As a first step, we should at least empower tool authors to detect if their tools aren't available when they're used in the build. I wrote https://github.com/dotnet/sdk/issues/38883 to capture this need.

gennmukhin commented 4 months ago

This is really necessary feature.