简体   繁体   中英

Nuget-package not adding package reference

I am trying to install MySql.Data and MySql.Data.Entity to my class lib.

Somehow there is no reference added to the project.

Things I've tried:

  1. Update-Package -reinstall (does not help)
  2. packages.config contains the correct entries
  3. *.csproj also has the correct entries
  4. Cleared NuGet-Cache

This is the output:

Package 'MySql.Data.6.10.6' already exists in folder 
'C:\Users\MYUSERNAME\Documents\Repositories\XXXXXXX\packages'
Added package 'MySql.Data.6.10.6' to 'packages.config'
Successfully installed 'MySql.Data 6.10.6' to XXXXXXXX.Persistence
Executing nuget actions took 1,6 sec

在此处输入图片说明

Strange thing is that NuGet creates that \\docs in my project which is part of MySql

Nuget-package not adding package reference

I agree with Matt`s comment. You project targets framework should be .NET 4.5.1 or below. Because the package MySql.Data only contain assembly reference to .NET framework 4.5.2 for .NET framework:

在此处输入图片说明

However, this package also have the content files, which are compatible with .net framework. So when you add this package to the project(target framework 4.5.1 or below), nuget will install this nuget package without any error, just add the content file ( \\docs ) but not add any reference to the project .

To resolve this issue, you can change the target framework to 4.5.2 and above of this project or you should use the nuget package MySql.Data with the version 6.9.11 , which contain assembly reference to .NET framework 4.0 and 4.5 :

在此处输入图片说明

Note: If you change the target framework to the .net framework 4.5.2 and above, you may get the error " The package 'MySql.Data' tried to add a framework reference to 'System.ComponentModel' which was not found in the GAC. ", please add a manually reference to missed library:

Package tried to add reference to System.Runtime which was not found in the GAC

Hope this helps.

I experienced this problem even though I had the correct Framework. It was solved by Migrating the Nuget Format to Package References

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM