jmrog / vscode-nuget-package-manager

An extension for Visual Studio Code that lets you easily add or remove .NET Core 1.1+ package references to/from your project's .csproj file using Code's Command Palette.
MIT License
34 stars 17 forks source link

Adding System.Linq or other dependencies allows you to add non-compatible versions with VSC runtime that later fails during compilation #28

Open calirails opened 6 years ago

calirails commented 6 years ago

When using NuGet to add the System.Linq and Selenium.WebDriver, I am allowed to select different versions, including those that are not compatible with my project type. In my case I am using Visual Studio Code with C# extensions on Mac. I believe my runtime configuration is running on .Net SDK 2.0, and is not compatible with all of the listed packages. Is there a way to add filters to Nuget to only list compatible versions or to show which ones are. Coincidentally running the dotnet CLI works because it auto resolves to the latest compatible version. In my case I had to select version 4.3.0 instead of 4.0.0 of System.Linq.

Repro Steps

1. Install Visual Studio Code (VSC) versiom 1.17.1 for MAC OSX from https://code.visualstudio.com/download

2. Download and install .Net Core and C# Extensions

3. Create console app via dotnet CLI by running:

 $ dotnet new console -o ./bbpBrowserRun

4. Launch VSC and open project folder corresponding to the console app

5. Within VSC, when prompted, click "Yes" to install missing dependencies

6. At this point, you can comopile, and debug the program (via F5) with break points. Everything works as expected

7. Now use NuGet to add LINQ (System.Linq version 4.0.0) dependencies

 a. With the Package Manager, type in "System.Linq" to narrow down the search
 b. Select System.Linq version 4.0.0
 => In my zipped file, the project also contains a dependency to Selenium WebDriver since I am trying to write a small page scraping app for internal use
    These Dependencies are listed in the bbpBrowserRun.csproj
       i.  System.Linq (version 4.0.0)
       ii. Selenium WebDriver (version 3.6.0)

8. Within VSC, try starting the debugger and observe these errors.

...bbpBrowserRun.csproj : error NU1605: Detected package downgrade: System.Linq from 4.3.0 to 4.0.0. Reference the package directly from the project to select a different version. ...bbpBrowserRun.csproj : error NU1605: bbpBrowserRun (>= 1.0.0) -> Selenium.WebDriver (>= 3.6.0) -> Newtonsoft.Json (>= 10.0.3) -> NETStandard.Library (>= 1.6.1) -> System.Linq (>= 4.3.0)