I've got a class library that till today was for .NET 4.5, now I've been asked to port it to .NET 40 but I've got some difficulies. I've followed this approach
and it works for the nuget packages that
but using this approach I get an error when going to Manage Nuget Packages telling
What's the most clean way to target different .NET framework version without loosing nuget package manager?
UPDATE #1
I've this version of nuget package manager
The error message caused by the duplicate packages listed in packages.config file. Because the Manager NuGet Packages window will read the packages.config file to list installed packages in your project and manage them.
For your situation, please check whether the packages in your project could compatible with both of .NET 4.5 and .NET 4.0. If yes, you need not to use two version packages in one project. You just need to change the project .NET Framework through Project -> Properties -> Application -> Target Framework.
If the installed packages version could not compatible with .NET 4.5 and .NET 4.0 at the same time, and you still want to use the Manager NuGet Packages, I suggest you do with below manual operation: Comment out one version of the packages in packages.config file and then open Manager NuGet Packages. After using Manager NuGet Packages, please uncomment the version that commented before.
Related
We have a solution with two projects (both version .net 4.6.2).
When installing a nuget package from our private Nuget Feed to either one of the projects, it works.
If we try to install the same package version into both projects, then package gets installed into one of them, and the other one gives error : "Error Could not install package 'OurInternalPackageName 1.0.1.5'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.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. ".
We tried installing nuget using 'Manage packages for solution' option, manage nuget packages for projects separately but the result is still the same.
Changing .NET framework versions does not help.
Clearing Nuget cache did not help as well.
The workaround we are using now: install package to one of the projects, and then install a lower version of a package to another project.
We tested this with 'Automapper' Nuget, tried to install into both projects and it worked (Same version got installed into both projects).
Any ideas would be appreciated.
I'm trying to install Dapper 2.0.4 via nuget manager as i want to use the latest Dapper.Contrib features
It didn't proceed due to the following error:
Could not install package 'Dapper 2.0.4'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', 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.
If i install the lower version (1.6), the installation went successful but i can't use the latest Contrib features.
How can i resolve this?
Hoping for your kind help. Thank you.
I tried the following and it worked for me.
Check Target Framework by right-clicking on the project and selecting the Application tab. If the target framework is .NET framework 4.6.1
Install-Package Dapper -Version 2.0.4 works fine.
If the target framework is less than 4.6.1 (In my case another project has target framework 4.5.2) try installing previous versions of Dapper for example:Install-Package Dapper -Version 1.50.2
Try this instead
Go to "Tools > NuGet Package Manager > NuGet Manager Settings > Package Sources
Once in Package Sources, set name to "Package Source" and Source to "https://www.nuget.org/api/v2/package/Dapper/" then update to save
Install .Net Framework SDK version 4.7.1 minimum.
Select installed target as a Target Framework for all Projects in your Solution
(in Project properties).
Retarget all packages in all projects executing update-package -reinstall -
ignoreDependencies from the Package Manager Console.
Install Dapper.
That should do it for you.
Install .Net Framework SDK version 4.7.1 minimum.
Select installed target as a Target Framework for all Projects in your Solution (in Project properties).
Retarget all packages in all projects executing update-package -reinstall -ignoreDependencies from the Package Manager Console.
Install Dapper.
UPDATE (from comments):
Dapper needs .NET Standard 2.0. Please retry the whole procedure including re-targeting with .NET Framework 4.7.2 as this is the first fully compliant with. Source: weblog.west-wind.com/posts/2019/Feb/19/
I am working on a Visual Studio solution with two projects which I will call Red.dll and Blue.dll for the purpose of this question. Note that Red.dll depends on Blue.dll. These are both compiled in .NET Standard 2.0 with the output type of "Class Library".
I added the dll of each project to a common NuGet package called "Red" using NuGet Package Explorer. It has the following structure:
lib
- netstandard2.0
- Red.dll
- Red.xml
- Blue.dll
- Blue.xml
Here is the problem: When I attempt to install this NuGet package to a .NET Core application, I receive the following error:
Error NU1101: Unable to find package Blue.dll. No packages exist with this id in source(s): Desktop, Microsoft Visual Studio Offline Packages, nuget.org
Blue.dll is not a NuGet package. I don't know why it thinks it is.
Blue.dll is located directly beside Red.dll.
There are no external dependencies other than Newtonsoft.Json which is irrelevant.
And to reiterate, Blue.dll is NOT a NuGet package dependency. I realize if you use the "Pack" feature in Visual Studio it will create a dependency, but I created this NuGet package manually to avoid that.
But most importantly: This all works perfectly in .NET Framework! The NuGet package successfully installed, both dlls are referenced, the code builds without any errors, and the XML documentation is accessible.
Why does this work in .NET Framework but not .Net Core?
I haven't found anything else online about this particular problem.
I am trying to write some unit tests in C# in a '.NETFramework,Version=v4.5.2' application but all tests give the next error:
'System.IO.FileNotFoundException : Could not load file or assembly
'System.Drawing.Common, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file
specified.'
When I try to install System.Drawing.Common I get the next error from the NuGet package:
Could not install package 'System.Drawing.Common 4.5.1'. You are trying to install this package into a project that targets
'.NETFramework,Version=v4.5.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.
I cannot change the application version or the framework (.NET Core 2.1) and any other trick I found online did not work (or generated more errors).
Help?
in NuGet put this line :
Install-Package System.Drawing.Common -Version 4.5.2
in .NET CLI put :
dotnet add package System.Drawing.Common --version 4.5.2
in Paket CLI put :
paket add System.Drawing.Common --version 4.5.2
Had the same problem. I have cloned solution https://github.com/barnhill/barcodelib . It has two projects: library project targets .Net Standard 2.0 and refers to System.Drawings.Common. Example project depends on library and has reference to System.Drawings.Common. Example project was not compiling due to same error.
My solution was just to remove reference to System.Drawings.Common in nuget packages and readd it (rclick on Example project > Manage nuget packages > Browse Installed, remove the System.Drawings.Common package, and then add it back), unload project and then reload it again
Helped for me.
I managed to solve it by restarting Visual Studio, changing the framework to 4.6.1 (which I could not do before) and adding the reference.
OP's solution migrated from the question to an answer.
you could try to use one of the libs described in here instead https://devblogs.microsoft.com/dotnet/net-core-image-processing/
you could try to use https://www.nuget.org/packages/CoreCompat.System.Drawing/ as well and maybe try to change your app framework to .net standard 2.0?
This is kind of bizarre but it worked dramatically so I'm going to mention it. I built a small vs 2017 ent console project that was supposed to read an oracle database. When I started to run it I got the System.Drawing.Common error mentioned above. It seemed stupid because I wasn't really doing anything having to do with Drawing at all. In Manage Nuget Packages I deleted the Oracle.ManagedDataAccess driver and added the Oracle.ManagedDataAccess.Core and the System.Drawing.Common error went away and I was able to read my oracle database. So I'm suggesting that with NuGet you may be picking up some things you really don't need and if you have any choice for your NuGet packages, try different ones. This also may be some foible with how my organization managed nuget for Visual Studio 2017 enterprise.
My ASP.NET MVC 5 EF 6 Application crashed because "System.Data.Entity.Core.UpdateException,EntityFramework, Version=6.0.0.0" was not found. I was wondering about the version 6.0 because I'm using the latest version 6.1.3.0 but I couldn't found any references to 6.0.0.0 which may cause this problem.
The solution to delete all temp ASP.NET files had no effect. Using NuGet, I downgraded the EntityFramework package from 6.1.3.0 to 6.0.0.0 and now everything works fine. But I want also to understand why this problem happened. My read is, that some other references are depending on EF in version 6.0.0.0 but I couldn't find out which ones.
I looked in the dependency-information of every installed NuGet package. The only one which refers to EntityFramework is MySQL.Data.Entity but not for the exact version 6.0.0.0, according to the info text he needs a version >= 6.0.0.0 so it should work fine with 6.1.3.0. Is there a way to let me see all assemblys depending on EntityFramework so that I can see which one depends on 6.0.0.0?
You may have two projects in your solution one using EF version 6.0.0 and the other project using 6.1.3.0.
If that is not the case consider updating all Nuget packages by right clicking on the project and Manage Nuget packages, then update all nuget packages.
Hope that helps.
First Manually install Entity-Framework-6.0 version on your project.
Open Console Package Manager in "Visual Studio" and execute this code
Install-Package EntityFramework -Version 6.0.0
And later Restart your solution and Right Click on Project select Manage Nuget Packages menu. Remove "Entity Framework 6.0.0" to all project and install Entity Framework last version on Nuget Packages Manager.
https://www.nuget.org/packages/EntityFramework/6.0.0