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

Why nuget install many dll dependenices in FFW 4.6.1 for the the package CommandLineParser, while only one package is installed in FFW 4.6 and 4.5 #7263

Closed
moh-hassan opened this issue Sep 3, 2018 · 3 comments
Labels
Functionality:Install The install command in VS/nuget.exe Resolution:ByDesign This issue appears to be ByDesign

Comments

@moh-hassan
Copy link

## Details about Problem

NuGet product used (NuGet.exe | VS UI : VS UI
NuGet version (4.3.0.4406)
VS version (if appropriate):VS 2017 update3
OS version (i.e. win10 v1607 (14393.321)): windows7 sp1

## Detailed repro steps so we can see the same problem:
Create console project FFW 4.6 in vs 2017 update 3
Run the command: Install-Package CommandLineParser

result: Only one package is installed (last version v2.3)

UnInstall-Package CommandLineParser

Change the properties of the project to FFW 4.6.1

Install-Package CommandLineParser

result: Many package are installed with CommandLineParser

The contents of package.config file are:

		<?xml version="1.0" encoding="utf-8"?>
		<packages>
		  <package id="CommandLineParser" version="2.3.0" targetFramework="net461" />
		  <package id="System.Collections" version="4.0.11" targetFramework="net461" />
		  <package id="System.Console" version="4.0.0" targetFramework="net461" />
		  <package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net461" />
		  <package id="System.Globalization" version="4.0.11" targetFramework="net461" />
		  <package id="System.IO" version="4.1.0" targetFramework="net461" />
		  <package id="System.Linq" version="4.1.0" targetFramework="net461" />
		  <package id="System.Linq.Expressions" version="4.1.0" targetFramework="net461" />
		  <package id="System.Reflection" version="4.1.0" targetFramework="net461" />
		  <package id="System.Reflection.Extensions" version="4.0.1" targetFramework="net461" />
		  <package id="System.Reflection.TypeExtensions" version="4.1.0" targetFramework="net461" />
		  <package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net461" />
		  <package id="System.Runtime" version="4.1.0" targetFramework="net461" />
		  <package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net461" />
		</packages>

The package CommandLineParser has multi-target net40, net45 and netstandard1.5.

The package has no dependency in case of net45 and net40, but in netstandard1.5 it has a dependency of the above listed packages.
see dependencies in package site:

What is the problem:
Why in Full Framework 4.6.1 (also 4.6.2) all these packages are installed, While in 4.6 and 4.5, only one package is installed.
It seems that nuget selects netstandard1.5 package with its dependencies .
The project isn't netstandard1.5 but FFW 4.6.1.

How to avoid installing all these package?

@PatoBeltran
Copy link

Hey @moh-hassan. thanks for opening the issue. This happens because netstandard1.5 is closer to net461 than the other target frameworks the package has, therefore we take that as our best option. You can read more about net standard here.

Here is a similar issue to this. As that issue says:

Ideally suave (in your case CommandLineParser) should contain a group without the netstandard dependencies that specifically targets .NETFramework to avoid unneeded dependencies.

I would suggest contacting the package owner and working with them to get this fixed! Let me know if this answers your question.

@PatoBeltran PatoBeltran added Resolution:ByDesign This issue appears to be ByDesign Functionality:Install The install command in VS/nuget.exe labels Sep 5, 2018
@moh-hassan
Copy link
Author

moh-hassan commented Sep 6, 2018

@PatoBeltran
Thanks for reply and your smart suggestion.
AS POC, I modified CommandLineParser.nuspec inside the package
I added the following empty group dependency for net45

    <group targetFramework="net45"/>

The final dependency in CommandLineParser.nuspec is as follows:

	<dependencies>
	   <group targetFramework="net45"/>
	  <group targetFramework=".NETStandard1.5">
		<dependency id="System.Collections" version="4.0.11-rc2-24027" />
		<dependency id="System.Console" version="4.0.0-rc2-24027" />
		<dependency id="System.Diagnostics.Debug" version="4.0.11-rc2-24027" />
		<dependency id="System.Globalization" version="4.0.11-rc2-24027" />
		<dependency id="System.IO" version="4.1.0-rc2-24027" />
		<dependency id="System.Linq" version="4.1.0-rc2-24027" />
		<dependency id="System.Linq.Expressions" version="4.0.11-rc2-24027" />
		<dependency id="System.Reflection" version="4.1.0-rc2-24027" />
		<dependency id="System.Reflection.Extensions" version="4.0.1-rc2-24027" />
		<dependency id="System.Reflection.TypeExtensions" version="4.1.0-rc2-24027" />
		<dependency id="System.Resources.ResourceManager" version="4.0.1-rc2-24027" />
		<dependency id="System.Runtime" version="4.1.0-rc2-24027" />
		<dependency id="System.Runtime.Extensions" version="4.1.0-rc2-24027" />
	  </group>           
	</dependencies>

I test by loading the package from file system as POC and ONE and only one package is installed :) in net461, 462 and even net471.
No more netstandard15 packages are installed.

nuget tool says:

Attempting to gather dependency information for package 'CommandLineParser.2.3.0' with respect to project 'Comand23', targeting '.NETFramework,Version=v4.6.1'
Gathering dependency information took 0.45 ms
Attempting to resolve dependencies for package 'CommandLineParser.2.3.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'CommandLineParser.2.3.0'
Resolved actions to install package 'CommandLineParser.2.3.0'
Retrieving package 'CommandLineParser 2.3.0' from 'local'.
Adding package 'CommandLineParser.2.3.0' to folder 'H:\projects\commandline\Comand23\packages'
Added package 'CommandLineParser.2.3.0' to folder 'H:\projects\commandline\Comand23\packages'
Added package 'CommandLineParser.2.3.0' to 'packages.config'
Successfully installed 'CommandLineParser 2.3.0' to Comand23
Executing nuget actions took 879.65 ms
Time Elapsed: 00:00:00.9939733

packages.config file contents is becoming:

  <?xml version="1.0" encoding="utf-8"?>
    <packages>
       <package id="CommandLineParser" version="2.3.0" targetFramework="net461" />
   </packages>

I will contact the package owner and working with them to get CommandLineParser.nuspec fixed

Many thanks for help and support.

@PatoBeltran
Copy link

Awesome to hear that! Will close this issue since it has been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Install The install command in VS/nuget.exe Resolution:ByDesign This issue appears to be ByDesign
Projects
None yet
Development

No branches or pull requests

2 participants