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

.NET Local Tools do not allow non-default Framework when Tool doesn't support default Framework #18205

Closed
jzabroski opened this issue Jun 10, 2021 · 2 comments
Labels
untriaged Request triage from a team member

Comments

@jzabroski
Copy link

jzabroski commented Jun 10, 2021

Problem statement

@KathleenDollard In #3115, the SDK project chose to deprecate DotNetCliToolReference for good reason. However, .NET Local Tools have some limitations that become obvious when certain Microsoft DotNetCliToolReference projects haven't been kept up to date OOB with respect to major .NET versions.

Ex: Microsoft.Web.Xdt is a tool you can install in a TFM net48 Microsoft.NET.Sdk project, via DotNetCliToolReference. Installing that same tool locally currently causes the SDK tooling to choose the default framework, which is .NET 5.0. It then fails to install the tool, with a confusing error message.

Steps to Reproduce

Attempt to use -v d for detailed verbosity to understand why Microsoft.Web.Xdt can't be installed

I have elided most of the verbose logging, and focused mostly on the part I think causes the issue.

dotnet.exe tool install -v d --local Microsoft.Web.Xdt

Error message below. Note the lines that say:

     Checking compatibility for Microsoft.Web.Xdt 3.1.0 with net5.0 (any).
 1>D:\Users\John.Zabroski\AppData\Local\Temp\1\su2bgq0d.svv\restore.csproj : error NU1212: Invalid project-package combination for Microsoft.Web.Xdt 3.1.0. DotnetToolReference project style can only contain references of the DotnetTool type
     Incompatible packages: 1
       Using "RestoreTask" task from assembly "C:\Program Files\dotnet\sdk\5.0.203\NuGet.Build.Tasks.dll".
       Task "RestoreTask"
         (in) RestoreGraphItems Count '4'
         (in) RestoreDisableParallel 'False'
         (in) RestoreNoCache 'False'
         (in) RestoreIgnoreFailedSources 'False'
         (in) RestoreRecursive 'True'
         (in) RestoreForce 'False'
         (in) HideWarningsAndErrors 'False'
         (in) RestoreForceEvaluate 'False'
         (in) RestorePackagesConfig 'False'
         Running restore with 8 concurrent jobs.
         Reading project file D:\Users\John.Zabroski\AppData\Local\Temp\1\su2bgq0d.svv\restore.csproj.
         Restoring packages for D:\Users\John.Zabroski\AppData\Local\Temp\1\su2bgq0d.svv\restore.csproj...
         Restoring packages for .NETCoreApp,Version=v5.0...
           GET http://packages.simmaculate.com/nuget/Development/FindPackagesById()?id='microsoft.web.xdt'&semVerLevel=2.0.0
           GET https://api.nuget.org/v3-flatcontainer/microsoft.web.xdt/index.json
           OK http://packages.simmaculate.com/nuget/Development/FindPackagesById()?id='microsoft.web.xdt'&semVerLevel=2.0.0 194ms
           OK https://api.nuget.org/v3-flatcontainer/microsoft.web.xdt/index.json 74ms
         Resolving conflicts for net5.0...
         Scanning packages for runtime.json files...
         Restoring packages for net5.0/any...
         Resolving conflicts for net5.0/any...
         Skipping compatibility checks of the ridless graph for DotnetToolReference project type. This graph is not used.
         Checking compatibility of packages on net5.0 (any).
         Checking compatibility for restore 1.0.0 with net5.0 (any).
         Checking compatibility for Microsoft.Web.Xdt 3.1.0 with net5.0 (any).
     1>D:\Users\John.Zabroski\AppData\Local\Temp\1\su2bgq0d.svv\restore.csproj : error NU1212: Invalid project-package combination for Microsoft.Web.Xdt 3.1.0. DotnetToolReference project style can only contain references of the DotnetTool type
         Incompatible packages: 1
         Committing restore...
         Writing assets file to disk. Path: D:\Users\John.Zabroski\AppData\Local\Temp\1\pz32g0mb.0hn\project.assets.json
         Failed to restore D:\Users\John.Zabroski\AppData\Local\Temp\1\su2bgq0d.svv\restore.csproj (in 506 ms).

         NuGet Config files used:
             D:\Users\John.Zabroski\AppData\Roaming\NuGet\NuGet.Config
             C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

         Feeds used:
             https://api.nuget.org/v3/index.json
             http://packages.simmaculate.com/nuget/Development/
             C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
       Done executing task "RestoreTask" -- FAILED.
     1>Done building target "Restore" in project "restore.csproj" -- FAILED.
     1>Done Building Project "D:\Users\John.Zabroski\AppData\Local\Temp\1\su2bgq0d.svv\restore.csproj" (Restore target(s)) -- FAILED.

Build FAILED.

Attempt to specify framework to override the default of .NET 5.0

dotnet.exe tool install --framework net48  --local Microsoft.Web.Xdt

Error message:

The local option(--local) does not support the framework option (--framework).

Workarounds

I don't see any, in particular, immediately available.

One idea is that Microsoft should publish Microsoft.Web.Xdt out-of-box for .NET 5.0. I don't understand why they stopped publishing it after .NET Core 3.0.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Jun 10, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@jzabroski
Copy link
Author

Someone at Microsoft pointed out that Microsoft.Web.Xdt is not a CLI tool. I was switching back and forth between this library and https://www.nuget.org/packages/Microsoft.DotNet.Xdt.Tools/ - from there, I was able to deduce the root cause is the packageType is not Tool on this package. I will have to see if that fixes the problem, and then re-submit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

1 participant