Search code examples
.netnuget

How to troubleshoot weird nuget dependency


I've built a multi-target Nuget I call "mycompany.XP.Desktop"* that I try include in a legacy WPF (FW 4.7.2) project. The Nuget includes support for netstandard 2.0, which is compatible with FW 4.7.2. But when I add the package nuget fails with this message:

Install failed (project: wpfClient_fw472, package: mycompany.XP.Desktop v1.0.0-beta.20) Could not install package 'Microsoft.AspNetCore.WebUtilities 8.0.0-rc.2.23480.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

As I do not reference pre-release packages in general, or the Microsoft.AspNetCore.WebUtilities package in particular, I assumed it must be a transitive dependency so I ran the dotnet list package --include-transitive command, and I got this:

Project 'mycompany.XP.Desktop' has the following package references
   [netstandard2.0]: 
   Top-level Package                             Requested   Resolved
   > Microsoft.AspNetCore.DataProtection         7.0.5       7.0.5   
   > Microsoft.AspNetCore.SignalR.Client         7.0.10      7.0.10  
   > Microsoft.Extensions.Hosting                6.0.0       6.0.0   
   > NETStandard.Library                   (A)   [2.0.3, )   2.0.3   

   Transitive Package                                             Resolved     
   > Azure.Core                                                   1.10.0       
   > Microsoft.AspNetCore.Authentication.Abstractions             2.2.0        
   > Microsoft.AspNetCore.Authentication.Core                     2.2.0        
   > Microsoft.AspNetCore.Authorization                           2.2.0        
   > Microsoft.AspNetCore.Authorization.Policy                    2.2.0        
   > Microsoft.AspNetCore.Connections.Abstractions                7.0.10       
   > Microsoft.AspNetCore.Cryptography.Internal                   7.0.5        
   > Microsoft.AspNetCore.DataProtection.Abstractions             7.0.5        
   > Microsoft.AspNetCore.Hosting.Abstractions                    2.2.0        
   > Microsoft.AspNetCore.Hosting.Server.Abstractions             2.2.0        
   > Microsoft.AspNetCore.Http                                    2.2.0        
   > Microsoft.AspNetCore.Http.Abstractions                       2.2.0        
   > Microsoft.AspNetCore.Http.Connections.Client                 7.0.10       
   > Microsoft.AspNetCore.Http.Connections.Common                 7.0.10       
   > Microsoft.AspNetCore.Http.Extensions                         2.2.0        
   > Microsoft.AspNetCore.Http.Features                           2.2.0        
   > Microsoft.AspNetCore.Mvc.Abstractions                        2.2.0        
   > Microsoft.AspNetCore.Mvc.Core                                2.2.5        
   > Microsoft.AspNetCore.ResponseCaching.Abstractions            2.2.0        
   > Microsoft.AspNetCore.Routing                                 2.2.0        
   > Microsoft.AspNetCore.Routing.Abstractions                    2.2.0        
   > Microsoft.AspNetCore.SignalR.Client.Core                     7.0.10       
   > Microsoft.AspNetCore.SignalR.Common                          7.0.10       
   > Microsoft.AspNetCore.SignalR.Protocols.Json                  7.0.10       
   > Microsoft.AspNetCore.WebUtilities                            2.2.0        
   > Microsoft.Azure.Functions.Worker.Core                        1.14.0       
   > Microsoft.Bcl.AsyncInterfaces                                7.0.0        
   > Microsoft.CSharp                                             4.5.0        
   > Microsoft.DotNet.PlatformAbstractions                        2.1.0        
   > Microsoft.Extensions.Configuration                           6.0.0        
   > Microsoft.Extensions.Configuration.Abstractions              7.0.0        
   > Microsoft.Extensions.Configuration.Binder                    6.0.0        
   > Microsoft.Extensions.Configuration.CommandLine               6.0.0        
   > Microsoft.Extensions.Configuration.EnvironmentVariables      6.0.0        
   > Microsoft.Extensions.Configuration.FileExtensions            6.0.0        
   > Microsoft.Extensions.Configuration.Json                      6.0.0        
   > Microsoft.Extensions.Configuration.UserSecrets               6.0.0        
   > Microsoft.Extensions.DependencyInjection                     7.0.0        
   > Microsoft.Extensions.DependencyInjection.Abstractions        7.0.0        
   > Microsoft.Extensions.DependencyModel                         2.1.0        
   > Microsoft.Extensions.Features                                7.0.10       
   > Microsoft.Extensions.FileProviders.Abstractions              7.0.0        
   > Microsoft.Extensions.FileProviders.Physical                  6.0.0        
   > Microsoft.Extensions.FileSystemGlobbing                      6.0.0        
   > Microsoft.Extensions.Hosting.Abstractions                    7.0.0        
   > Microsoft.Extensions.Logging                                 7.0.0        
   > Microsoft.Extensions.Logging.Abstractions                    7.0.1        
   > Microsoft.Extensions.Logging.Configuration                   6.0.0        
   > Microsoft.Extensions.Logging.Console                         6.0.0        
   > Microsoft.Extensions.Logging.Debug                           6.0.0        
   > Microsoft.Extensions.Logging.EventLog                        6.0.0        
   > Microsoft.Extensions.Logging.EventSource                     6.0.0        
   > Microsoft.Extensions.ObjectPool                              2.2.0        
   > Microsoft.Extensions.Options                                 7.0.1        
   > Microsoft.Extensions.Options.ConfigurationExtensions         6.0.0        
   > Microsoft.Extensions.Primitives                              7.0.0        
   > Microsoft.IdentityModel.Abstractions                         6.25.1       
   > Microsoft.IdentityModel.JsonWebTokens                        6.25.1       
   > Microsoft.IdentityModel.Logging                              6.25.1       
   > Microsoft.IdentityModel.Tokens                               6.25.1       
   > Microsoft.Net.Http.Headers                                   2.2.8        
   > Microsoft.NETCore.Platforms                                  1.1.0        
   > Microsoft.NETCore.Targets                                    1.1.0        
   > Microsoft.Win32.Registry                                     5.0.0        
   > Newtonsoft.Json                                              9.0.1        
   > runtime.native.System                                        4.0.0        
   > System.AppContext                                            4.1.0        
   > System.Buffers                                               4.5.1        
   > System.Collections                                           4.0.11       
   > System.Collections.Immutable                                 5.0.0        
   > System.ComponentModel.Annotations                            5.0.0        
   > System.Diagnostics.Debug                                     4.0.11       
   > System.Diagnostics.DiagnosticSource                          7.0.0        
   > System.Diagnostics.EventLog                                  6.0.0        
   > System.Diagnostics.Tools                                     4.0.1        
   > System.Dynamic.Runtime                                       4.0.11       
   > System.Formats.Asn1                                          7.0.0        
   > System.Globalization                                         4.0.11       
   > System.IdentityModel.Tokens.Jwt                              6.25.1       
   > System.IO                                                    4.1.0        
   > System.IO.FileSystem                                         4.0.1        
   > System.IO.FileSystem.Primitives                              4.0.1        
   > System.IO.Pipelines                                          7.0.0        
   > System.Linq                                                  4.1.0        
   > System.Linq.Expressions                                      4.1.0        
   > System.Memory                                                4.5.5        
   > System.Memory.Data                                           1.0.1        
   > System.Numerics.Vectors                                      4.5.0        
   > System.ObjectModel                                           4.0.12       
   > System.Reflection                                            4.1.0        
   > System.Reflection.Emit                                       4.0.1        
   > System.Reflection.Emit.ILGeneration                          4.0.1        
   > System.Reflection.Emit.Lightweight                           4.0.1        
   > System.Reflection.Extensions                                 4.0.1        
   > System.Reflection.Primitives                                 4.0.1        
   > System.Reflection.TypeExtensions                             4.1.0        
   > System.Resources.ResourceManager                             4.0.1        
   > System.Runtime                                               4.3.0        
   > System.Runtime.CompilerServices.Unsafe                       6.0.0        
   > System.Runtime.Extensions                                    4.1.0        
   > System.Runtime.Handles                                       4.0.1        
   > System.Runtime.InteropServices                               4.1.0        
   > System.Runtime.InteropServices.RuntimeInformation            4.0.0        
   > System.Runtime.Serialization.Primitives                      4.1.1        
   > System.Security.AccessControl                                6.0.0        
   > System.Security.Cryptography.Cng                             5.0.0        
   > System.Security.Cryptography.Pkcs                            7.0.0        
   > System.Security.Cryptography.Xml                             7.0.1        
   > System.Security.Principal.Windows                            5.0.0        
   > System.Text.Encoding                                         4.3.0        
   > System.Text.Encoding.Extensions                              4.0.11       
   > System.Text.Encodings.Web                                    7.0.0        
   > System.Text.Json                                             7.0.3        
   > System.Text.RegularExpressions                               4.1.0        
   > System.Threading                                             4.0.11       
   > System.Threading.Channels                                    7.0.0        
   > System.Threading.Tasks                                       4.0.11       
   > System.Threading.Tasks.Extensions                            4.5.4        
   > System.Xml.ReaderWriter                                      4.0.11       
   > System.Xml.XDocument                                         4.0.11       
   > mycompany.XP.Auth                                             1.0.0-beta.19
   > mycompany.XP.Auth.Abstractions                                1.0.0-beta.19
   > mycompany.XP.Auth.TokensAndCredentials                        1.0.0-beta.19
   > mycompany.XP.Browsers                                         1.0.0-beta.19
   > mycompany.XP.Caching                                          1.0.0-beta.19
   > mycompany.XP.Caching.Abstractions                             1.0.0-beta.19
   > mycompany.XP.Caching.DataProtection                           1.0.0-beta.19
   > mycompany.XP.Common                                           1.0.0-beta.19
   > mycompany.XP.Configuration                                    1.0.0-beta.19
   > mycompany.XP.DependencyInjection                              1.0.0-beta.19
   > mycompany.XP.Diagnostics                                      1.0.0-beta.19
   > mycompany.XP.Documentation                                    1.0.0-beta.19
   > mycompany.XP.DynamicEntities                                  1.0.0-beta.19
   > mycompany.XP.Identity                                         1.0.0-beta.19
   > mycompany.XP.Logging                                          1.0.0-beta.19
   > mycompany.XP.Logging.Abstractions                             1.0.0-beta.19
   > mycompany.XP.OAuth2                                           1.0.0-beta.19
   > mycompany.XP.Serialization                                    1.0.0-beta.19
   > mycompany.XP.Streaming                                        1.0.0-beta.19
   > mycompany.XP.StringValues                                     1.0.0-beta.19
   > mycompany.XP.Web                                              1.0.0-beta.19
   > mycompany.XP.Web.Abstractions                                 1.0.0-beta.19
   > mycompany.XP.Web.Http                                         1.0.0-beta.19
   > mycompany.XP.Web.Services                                     1.0.0-beta.19

My meticulously investigating all of my 36 nuget projects, I found one - mycompany.XP.Identity - that transitively depends on Microsoft.AspNetCore.WebUtilities, via a reference to Microsoft.AspnetCore.Http (which provides extension method to register IHttpContextAccessor service). So, it's fine that it has a dependency to that nuget, but I simply can't understand why nuget resolves it needs to include the very latest release candidate, instead of the 2.2.0 version.

I even tried explicitly include the 2.2.0 verison in the mycompany.XP.Identity project, rebuild the nugets, and try again. But the same thing still happens, and nuget still complains it can't include the RC version due to incompatibilty.

Is there some setting somewhere I might have flipped by mistake, that forces nuget to behave like this?

How do I troubeshoot these kinds of Nuget issues?

* The actual name of my company was replaced with 'mycompany'


Solution

  • Turns out it was just Rider misbehaving. I tested adding my Nuget to the project using VS2022 instead and that resolved the proper dependencies - not including any pre-released versions. Might be Rider isn't good at legacy stacks, like FW 4.7.2. I'll file it as a bug to JetBrains.