NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

defect w/packages.config resolver causes circular NuGet dependency installation failures - works fine w/PackageReference #5751

Open ghuntley opened 7 years ago

ghuntley commented 7 years ago

Details about Problem

This defect is quasi-blocking the release of netstandard edition of ReactiveUI.

See https://github.com/reactiveui/ReactiveUI/issues/1413

We have a workaround but it involves asking people to change their visual studio configuration to use PackageReference instead of packages.config as their resolver. I don't want to release without having this problem fixed because the amount of pain it will cause to our users and the maintainers telling them to RTFM/release-notes as packages.config is the default option in Visual Studio

image

Package Manager Console Host Version 4.2.0.2457

Microsoft Visual Studio Enterprise 2017 
Version 15.2 (26430.16) Release
VisualStudio.15.Release/15.2.0+26430.16
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools   00369-60000-00001-AA183
Microsoft Architecture Diagrams and Analysis Tools

Visual Basic 2017   00369-60000-00001-AA183
Microsoft Visual Basic 2017

Visual C# 2017   00369-60000-00001-AA183
Microsoft Visual C# 2017

Visual C++ 2017   00369-60000-00001-AA183
Microsoft Visual C++ 2017

Visual F# 4.1   00369-60000-00001-AA183
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.6.00404.2
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30503.0
ASP.NET and Web Tools 2017

ASP.NET Web Frameworks and Tools 2017   5.2.50303.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30209.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.2.5000.0
Microsoft Azure Data Lake Tools for Visual Studio

CodeMaid   10.4.53
CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.

Common Azure Tools   1.9
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

JetBrains ReSharper Ultimate 2017.1.3    Build 108.0.20170613.154143
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2017 JetBrains, Inc.

KofePackagePackage Extension   1.0
KofePackagePackage Visual Studio Extension Detailed Info

License Header Manager   2.0.0
An extension for automatically inserting license information file headers.

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure Hive Query Language Service   2.2.5000.0
Language service for Hive query

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50131.1

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   Mono.Debugging.VisualStudio
Support for debugging Mono processes with Visual Studio.

NCrunch   
Continuous Testing Tool for .NET
Copyright © 2010-2017 Remco Software Ltd

NuGet Package Manager   4.2.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2017 ENU   15.0.26309
Microsoft Office Developer Tools for Visual Studio 2017 ENU

Open Command Line   2.1.179
Opens a command line at the root of the project. Support for all consoles such as CMD, PowerShell, Bash etc. Provides syntax highlighting, Intellisense and execution of .cmd and .bat files.

OzCode   1.0
Your road to Magical Debugging. http://www.oz-code.com

OzCodePackage Extension   1.0
OzCodePackage Visual Studio Extension Detailed Info

Redgate ReadyRoll   1.14.11.4593
Extend DevOps processes to your SQL Server databases and safely automate database deployments.

Visit https://www.red-gate.com/readyroll for more information.

Copyright (C) 2011 Red Gate Software Ltd. All rights reserved.

This software contains components from Component Owl.
SQL Server is a registered trademark of Microsoft Corporation. 
Visual Studio is a registered trademark of Microsoft Corporation. 

ReadyRoll contains code from the following open source software:

NuGet https://www.nuget.org/
SQL LocalDB Wrapper https://github.com/martincostello/sqllocaldb
Autofac https://autofac.org/
Json.NET https://json.net/
MahApps.Metro http://mahapps.com/
SemVer https://github.com/maxhauser/semver
Log4Net http://logging.apache.org/log4net/
Extended WPF Toolkit https://wpftoolkit.codeplex.com/
Code InfoBox VSX http://www.codeproject.com/Articles/55196/Code-InfoBox-Visual-Studio-Extension-VSX
OctoPack https://github.com/OctopusDeploy/OctoPack
SQLite https://sqlite.org/

This product contains icons from http://www.visualpharm.com distributed under a free backlink license.

For license details or other notices relating to the above software, please see NOTICE.TXT and EULA.rtf in the ReadyRoll application folder.

Redgate SQL Prompt   8.0.2.1513
Write, format, and refactor SQL effortlessly

SettingsWindow Extension   1.0
SettingsWindow Visual Studio Extension Detailed Info

SQL Server Data Tools   15.1.61702.140
Microsoft SQL Server Data Tools

Tizen.Extension.Package Extension   1.0
Tizen.Extension.Package Visual Studio Extension Detailed Info

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript   2.2.2.0
TypeScript tools for Visual Studio

Visual C++ for Linux Development   1.0.6
Visual C++ for Linux Development

Visual Studio tools for CMake   1.0
Visual Studio tools for CMake

Visual Studio Tools for Unity   3.1.0.0
Visual Studio Tools for Unity

Visual Studio Tools for Universal Windows Apps   15.0.26430.06
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

VsVim   2.4.1.0
VsVim is a Vim emulator for Visual Studio

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   4.5.0.486 (fec6f88)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.3.1.2 (9dbc4c5)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   10.10.0.37 (ad35de4)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

image

Detailed repro steps so we can see the same problem

See https://github.com/reactiveui/ReactiveUI/issues/1413

Ensure resolver is using packages.config

  1. File New Project -> Android
  2. PM> Install-Package ReactiveUI -version 8.0.0-alpha0034

💥

Change resolver to use PackageReference

  1. File New Project -> Android
  2. PM> Install-Package ReactiveUI -version 8.0.0-alpha0034

🎈 🎉 🎈

Same happens for other platforms (inc iOS, so please validate against all TFMs that ReactiveUI supports - see https://github.com/reactiveui/ReactiveUI/tree/develop/src)

Thank-you

@onovotny helped out with troubleshooting this early this morning and finding the workaround; thank-you Oren for taking the time out away from your family to help out.

clairernovotny commented 7 years ago

With 15.2 and 15.3, here's what I see:

PM> Install-Package ReactiveUI -version 8.0.0-alpha0034

Attempting to gather dependency information for package 'ReactiveUI.8.0.0-alpha0034' with respect to project 'App1', targeting 'MonoAndroid,Version=v7.1'
Gathering dependency information took 1.23 sec
Attempting to resolve dependencies for package 'ReactiveUI.8.0.0-alpha0034' with DependencyBehavior 'Lowest'
Install-Package : Circular dependency detected 'reactiveui 8.0.0-alpha0034 => System.Reactive 3.1.0 => System.Reactive.PlatformServices 4.0.0-preview00001 => 
System.Reactive 3.1.0'.
At line:1 char:1
+ Install-Package ReactiveUI -version 8.0.0-alpha0034
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Time Elapsed: 00:00:01.5002768
PM> 

The issue is that for some reason, System.Reactive 3.1.0 => System.Reactive.PlatformServices 4.0.0-preview00001 is happening. That should not be happening. The 4.x ones are not compatible with 3.x. As you can see from the PM output, DependencyBehavior 'Lowest' is there, so it shouldn't be jumping ahead.

JonDouglas commented 7 years ago

Just to add a quick bookkeeping item:

  1. I was using PackageReference
  2. I was using the NuGet Package Manager GUI in VS 2017 (15.2 Stable)
  3. I had Preview checked
  4. I installed ReactiveUI -version 8.0.0-alpha0034
  5. I still ran into the same Circular dependency issue.

However when I installed the same package from the console, it worked fine. I also suspect a GUI bug at play here. I can't check again because the package was unlisted from https://www.nuget.org/packages/reactiveui.

Thanks again for filing this!

emgarten commented 7 years ago

I see the circular dependency error when packages.config from both the UI and NuGet Console in VS. I do not see it when using PackageReference.

@JonDouglas can any additional steps you used to repro the difference between the UI and Console and share the output? They should behave the same.

emgarten commented 7 years ago

System.Reactive packages appear to have reversed dependency order between versions which is especially painful since the 3.x packages do not have an upper bound on the dependency ranges, which means that the circular combination is allowed.

System.Reactive.PlatformServices 4.0.0-preview00001 -> System.Reactive 4.0.0-preview00001
System.Reactive 3.1.0 -> System.Reactive.PlatformServices 3.1.0

When resolving packages NuGet does not attempt to look for other solutions if a circular dependency occurs, this is considered a package authoring error and it is usually better to fail with a helpful message there instead of potentially coming up with a very unexpected set of packages to workaround the problem automatically. Here you don't own these packages, so it isn't very helpful unfortunately.

@ghuntley I suggest updating ReactiveUI's nuspec to disallow the 4.x versions of the above packages. You could also move to >= 4.x, but the key here is to make sure that System.Reactive and System.Reactive.PlatformServices stay in sync.

<dependency id="System.Reactive" version="[3.1.0, 3.9999.0)" exclude="Build,Analyzers" />
<dependency id="Splat" version="2.0.0" exclude="Build,Analyzers" />
<dependency id="System.Reactive.PlatformServices" version="[3.1.0, 3.9999.0)" exclude="Build,Analyzers" />

Another workaround for users is to install System.Reactive.PlatformServices 3.1.0 first, then install ReactiveUI.

clairernovotny commented 7 years ago

@emgarten But why is it even considering a later version as valid in it's circular dependency order search? There's no circular dependency if you go with the "lowest" path... ?

It's also not just "PlatformServices," it's all of the original packages. They are now type-forwarding facades where the impl moved into System.Reactive. Before System.Reactive was just a meta-package that pulled in PlatformServices and many others.

Disallowing the 4.x version seems wrong as well since the whole purpose of the typefowarders is to allow libraries built with 3.x be used with Rx 4.x.

rrelyea commented 7 years ago

@onovotny answer to your first question: These packages are referencing system packages directly. This is causing it to try a higher version due to conflicts between the system packages.

We'd prefer to not invest in major changes in packages.config resolver changes...cost, danger, etc...

We understand that is troublesome here, but packages.config is not well designed for reversing dependency directions. Like many issues that customers are having with NuGet, we are trying to move the ecosystem to PackageReference. How does that sound?

alexdegroot commented 6 years ago

Is there a way in the SDK to avoid this behavior? I'm using the SDK to install NuGet packages in a specific folder. I try to avoid the issue by installing the PlatformServices first, but that won't work. Rather I'd simply like to say to the API: Ignore the old way of resolution.