-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Limit DotNetCliToolReference Tools to .NET Core 2.2 and Below #3115
Comments
I had to read twice to make sure I understood, you're saying this is still okay, right? This is just a restriction for the authors of a DotNetCliTool. <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<DotNetCliToolReference Include="dotnet-banana" Version="x.x.x" />
</ItemGroup>
</Project> |
yes. just dotnet-banana need to be targeting netcoreapp2.2 or lower |
Nate, if you have a wording suggestion to make this more clear, let me know. Do you think including your example is worthwhile? |
Oh, and "OK" is relative. It will still have the problems with transitive dependencies today. |
forget to close this issue. It is done. |
A drawback of making |
Local tools allow tools to be defined in a tool-manifest file, and you can then use You are correct that this is a separate gesture. Restoring with the rest of the project was problematic, partially because the runtime for the tool and the project was often not the same. We designed the tool strategy to avoid these problems and others. As a result, there are two gestures. |
That makes sense, however I think DotNetCliToolReference enabled the following two scenarios, which were nice (as in "nice to have"):
|
…0191005.6 (#3115) - Microsoft.NETCore.App - 5.0.0-alpha1.19505.6 Dependency coherency updates - Microsoft.NET.Sdk.WindowsDesktop - 5.0.0-alpha1.19504.4 (parent: Microsoft.NETCore.App) - System.CodeDom - 5.0.0-alpha1.19504.7 (parent: Microsoft.NETCore.App) - System.Security.Cryptography.ProtectedData - 5.0.0-alpha1.19504.7 (parent: Microsoft.NETCore.App) - System.Text.Encoding.CodePages - 5.0.0-alpha1.19504.7 (parent: Microsoft.NETCore.App)
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 |
@KathleenDollard Is there a plan to support the two scenarios I described above? Will (or does it already have one) Visual Studio have a UI to install and restore global tools in a solution? That in my view this would more or less solve scenario 1. (except for other .NET IDEs where this would need to be reimplemented). It would also solve scenario 2. if our template has already created or updated a manifest file. |
This was going to be our approach, but our CLI tool needs to load an assembly and the types that it depends on. Since .NET Core 2.X doesn't support multiple AppDomains or Refection Only assembly loading, this means that it could only load an assembly whose assembly dependencies don't target anything but .Net Core 2.X (since the tool already had those runtime assemblies loaded). This has become untenable, so I have to cobble together some sort of local tool solution now in order to work against .NET Core 3.X projects that have dependencies on .NET Core 3.X or .NET Standard 2.1 assemblies. |
@KathleenDollard As I see no answers above, I am adding another hardly (not-at-all) supported use case. I am publishing the library to NuGet which installed requires the dotnet CLI tool for code generation. So how can I add this requirement to nuspec? Should I just add Target with |
but .net core 2.2 sdk for example should be installed ? Although here https://github.com/madskristensen/BundlerMinifier/tree/master/src/BundlerMinifier.Core |
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 viadotnet <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
The text was updated successfully, but these errors were encountered: