question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Limit DotNetCliToolReference Tools to .NET Core 2.2 and Below

See original GitHub issue

Limit DotNetCliToolReference Tools to .NET Core 2.2 and Below

.NET Core 3 takes the next step in the .NET Core tool strategy with local tools. As part of this process, starting in Preview 4 DotNetCliToolReference tools will be restricted to targeting .NET Core 2.2 and below. DotNetCliToolReference tools can be used in projects targeting .NET Core 3.0, but the tools themselves should target .NET Core 2.2 or below.

Details

The suggested approach going forward is to to use .NET Core Local Tools when you want a tool that is specific to a project or repository. At the same time we are removing the need to access local tools by the verbose dotnet tool run <toolname> that was present in earlier previews. You can now access local tools via dotnet <toolname>.

DotNetCliToolReference tools have a flaw in how their dependencies are restored which can create difficult to diagnose bugs when running these tools. This issue would occur much more frequently if targeting .NET Core 3.0 was allowed. Restricting tools to target only .NET Core 2.2 and below means existing scenarios to continue to work (as well as they previously did), regardless of the framework version targeted by the project or the current .NET Core SDK.

The new .NET Core tool strategy avoids this flaw in restore strategy and offers other benefits, like the ability to author one type of tool and install it in different ways depending on project and user needs.

We look forward to your feedback on .NET Core Local Tools, and on challenges you face moving away from DotNetCliToolReference tools.

dotnet/sdk #3057

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
bitbonkcommented, Oct 22, 2019

That makes sense, however I think DotNetCliToolReference enabled the following two scenarios, which were nice (as in “nice to have”):

  1. Users sometimes did not have to use the CLI at all, they could stay in VS all the time: Tools where automatically restored when the user restored the regular nuget packages. And the installed tools would just do do their work under the hood (e.g. when the user builds the project). The user clones the repo in VS and everything just works in VS right away.

  2. When building a framework, it is nice to not have to write into the getting started documentation that you have to restore the nuget packges and some global tools. You would just create the project (with our template that already contains all required DotNetCliToolReference entries) and you are ready to go and can use all our tools right away.

4reactions
ascott18commented, Feb 14, 2020

Another use case we have for DotNetCliToolReference is a set of libraries that are used in conjunction with a code gen tool. Generally (although not strictly necessary), these should all be kept on identical version numbers. We used a prop in a Directory.Build.props file to control this version from a single location.

With the deprecation of DotnetCliToolReference, this won’t be possible anymore - we’ll have to make sure the version number is always updated in both locations when updating, which is going to be very error prone.

The separate command for restoring tools from the manifest is also rather undesirable from a usability point of view. Does attempting to execute the tool also perform the restore, similar to how dotnet build automatically does a dotnet restore? If not, this new approach is a non-starter for us and we’ll be forced to stay on netcoreapp2.2 for our CLI tool forever.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Version for package `Microsoft.EntityFrameworkCore.Tools ...
To use CLI tools, you first need to add <DotNetCliToolReference> items as you have already have. Then you call dotnet restore in the...
Read more >
Download .NET Core 2.2 (Linux, macOS, and Windows)
NET Core 2.2 downloads for Linux, macOS, and Windows. .NET is a free, cross-platform, open-source developer platform for building many different types of ......
Read more >
.NET Core Global Tools and Gotchas
The NuGet package that contains a global tool must completely contain the application. Unlike project tools (aka DotNetCliToolReference ), you ...
Read more >
.NET Core Global Tools for AWS | AWS Developer Tools Blog
To migrate this project, you need to delete the DotNetCliToolReference element, including Amazon.Lambda.Tools. If you don't remove this line ...
Read more >
.NET core vs .NET framework
NET Core provides a standard base library that's usable across Windows, Linux, macOS and mobile devices ... <DotNetCliToolReference Include="dotnet-xunit" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found