Dependencies error while installing packages with NuGet - nuget

I'm trying to install the following packages with NuGet on Visual Studio 2010
TweetSharp version 2.3.1 (which requires Newtonsoft.Json version 5.0.6)
SharpMap version 1.1.0 (which requires Newtonsoft.Json version 4.5.11)
using the following simple NuGet commands:
PM> Install-Package TweetSharp
PM> Install-Package SharpMap
however I'm getting the following dependencies error after installing the second package:
Install failed. Rolling back...
Install-Package : Updating 'Newtonsoft.Json 5.0.6' to 'Newtonsoft.Json 4.5.11' failed. Unable to find a version of 'TweetSharp' that is compatible with 'Newtonsoft.Json 4.5.11'.
At line:1 char:16
+ Install-Package <<<< SharpMap
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
is there anyway to fix this issue? thanks in advance.

The problem is that SharpMap has defined the dependency to be exactly
NewtonSoft.Json = 4.5.11
Not greater than or equal, but exactly equal. The best way forward is to contact the owners of the package and ask them to loosen the requirements. It's not very useful like it is, for exactly the reason demonstrated in this question.
However, you can attempt to use the -IgnoreDependencies switch:
> Install-Package SharpMap -IgnoreDependencies
This installs only SharpMap, so you'll need to explicitly install all the other dependencies (except NewtonSoft.Json) afterwards:
> Install-Package BruTile -Version 0.7.4.4
> Install-Package Common.Logging -Version 2.0.0
> Install-Package GeoAPI -Version 1.7.2
> Install-Package NetTopologySuite -Version 1.13.2
> Install-Package NetTopologySuite.IO -Version 1.13.2
> Install-Package ProjNET4GeoAPI -Version 1.3.0.3
However, SharpMap is still going to look for NewtonSoft.Json 4.5.11, so you'll need to add an assembly binding redirect in your application configuration file:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json"
publicKeyToken="30ad4fe6b2a6aeed"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.6.0"
newVersion="5.0.6.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
This may work, but I haven't tried, because in the end, it'll depend on how you want to use these two libraries together.
The shift in major versions of Json.NET indicates that there are breaking changes between 4.x and 5.0, so if SharpMap relies on some of the features of Json.NET 4.5.11 that are affected by the breaking changes, it's not going to work.
However, in my experience, using newer versions of Json.NET with libraries compiled against older versions tend to work fine, so it's worth a shot.

Related

Need to Update EF Core Tools

When I use the dotnet ef tools in the VS 2017 Package Manager Console I get a warning message about needing to update EF Core tools:
PM> dotnet ef migrations list -s ../RideMonitorSite
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.2-rtm-30932'. Update the tools for the latest features and bug fixes.
20180831043252_Initial
But my csproj file has this entry:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.2" />
</ItemGroup>
I've confirmed that the version installed is, in fact, out of date:
PM> dotnet ef --version
Entity Framework Core .NET Command-line Tools
2.1.1-rtm-30846
So what do I do to update the tools? BTW, I've seen in other answers that an out of date global.json file can cause this problem. But I don't have a global.json file anywhere in the solution.
Use command line, Cmd or PowerShell for specific version:
dotnet tool update --global dotnet-ef --version 3.1.0
or for latest version use (works also for reinstallation):
dotnet tool update --global dotnet-ef
I bounced this issue over to the development team over on github. Turns out this is a known issue in the current tooling or nuget packages that get loaded when you create an EF Core-powered AspNet Core site. It's targeted to be fixed in a future release.
For now, the workaround is simply to ignore the warning.
Another workaround is also offered, involving tweaking the csproj file to define the version of the AspNet Core metapackage explicitly -- it's up to 2.1.3 as I'm writing this -- but I couldn't get that approach to work; I still kept getting the warning message.
for .NET 6, it would be
dotnet tool update --global dotnet-ef --version 6.0.0
The solution that worked for me is running the following commands in Package Manager Console:
PM> Install-Package Microsoft.EntityFrameworkCore -Version 2.1.11
PM> Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.1.11
Make sure the version matches the one in the error message in my case I got the following error:
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.11-servicing-32099'. Update the tools for the latest features and bug fixes.
Check the versions available from the following site:
https://www.nuget.org/packages/Microsoft.EntityFrameworkCore/
Try this one:
Install-Package Microsoft.EntityFrameworkCore.Tools
If problem still occurs, then execute this also:
Update-Package Microsoft.EntityFrameworkCore.Tools
My solution was to install the tool dotnet-ef from microsoft https://www.nuget.org/packages/dotnet-ef. It uses the same commands but no warnings. The change is to use dotnet-ef instead of dotnet ef.
And if you already have dotnet-ef installed then use
dotnet tool update --global dotnet-ef --version n.n.n (n.n.n your version to update to)
To Solve This Issue You May Follow One Of The Following Techniques:
Technique 1: Using Package Manager Console(Especially for Microsoft Visual Studio user) PM> Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.1.2
Technique 2: Using .NET CLI > dotnet add package Microsoft.EntityFrameworkCore.Tools --version 2.1.2
Technique 3: Using Package Reference
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Technique 4: Using Packet CLI > paket add Microsoft.EntityFrameworkCore.Tools --version 2.1.2
Remember: For this version to use you need NuGet 3.6 or higher.
Reference Link: https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools/2.1.2
Install a new .NET Core SDK v2.1.401 version and check >dotnet ef --version again. I had the same issue and in my case, that worked. Also, you don't need to add Microsoft.EntityFrameworkCore.Tools.DotNet.
Ignore the issue
Do not update your < PackageReference Include = " Microsoft . EntityFrameworkCore . Tools " Version ="" / >
In my case, I moved forward with 'Update-Database -Context MyElementContext' and now it is all working fine.
I found this in the book 'Programming ASP.NET Core' by Dino Esposito.
'Note This version of the CLI tooling is not the same as the version of the .NET Core runtime the application will use. The runtime version is specified in the project file, and you can comfortably edit it from within the user interface of the IDE of your choice. If you want, instead, to edit the project file manually, then it is as easy as editing the .csproj XML fi le and changing the value of the TargetFramework element. The value refers to the moniker that identifies the version (such as netcoreapp2.0).'
Like Martin
Use command line, Cmd or PowerShell for specific version:
dotnet tool update --global dotnet-ef --version 3.1.0
or for latest version use (works also for reinstallation):
dotnet tool update --global dotnet-ef
But, I've got probleme in my pc :
"When running the command whitout specifying any version i got the following error: Tool 'dotnet-ef' failed to update due to the following: The tool package could not be restored" Liko Pippo46
So, I use these steps :
dotnet tool uninstall --global dotnet-ef
But got the same problem, so I'm going to the directory of the extension :
C:\Users\Evan.dotnet\tools.store\dotnet-ef
And I found the old version (2.x)
And my second problem was the file fileproject.assets.json was not found
So I copy the fileproject.assets.json in the 2.x version to the parent repository
And all was done perfectly :
dotnet tool uninstall --global dotnet-ef
removes the 2.x version
dotnet tool install --global dotnet-ef
install the 3.1 one
I couldn't find how to update the package specifically, but in the Package Manager Console I ran 'update-package'. It ran through and updated all packages referenced in a project, including the EF Core Tools. That may not be ideal for you as that could update packages you didn't want.
Following the steps in this document helped me solve the problem - https://docs.oracle.com/cd/E17952_01/connector-net-en/connector-net-entityframework-core-scaffold-example.html
Scaffolding a Database Using Package Manager Console in Visual Studio
Open Visual Studio and create a new Console App (.NET Core) for C#.
Add the MySQL NuGet package for EF Core using the Package Manager Console. For example, use the following command to add the MySql.Data.EntityFrameworkCore v8.0.13 package:
Install-Package MySql.Data.EntityFrameworkCore -Version 8.0.13
Important
The version (for example, -Version 8.0.13) must match the actual Connector/NET version you are using. For current version information.
Install the following NuGet packages by selecting either Package
Manager Console or Manage NuGet Packages for Solution from the Tools
and then NuGet Package Manager menu:
Microsoft.EntityFrameworkCore.Design
EF Core 1.1 only: Also add the MySql.Data.EntityFrameworkCore.Design package.
Microsoft.EntityFrameworkCore.Tools version 1.1.6 (for EF Core 1.1) and Microsoft.EntityFrameworkCore.Tools version 2.0.3 (for EF Core 2.0)
Note
The .NET tools are included in the .NET Core 2.1 SDK and not required or supported for EF Core 2.1. If this is an upgrade, remove the reference to that package from the .csproj file (version 2.0.3 in this example) :
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
Open Package Manager Console and enter the following command at the prompt to create the entities and DbContext for the sakila database (adjust the connection-string values to match your settings for the user= and password= options):
Scaffold-DbContext "server=localhost;port=3306;user=root;password=mypass;database=sakila"
MySql.Data.EntityFrameworkCore -OutputDir sakila -f
Visual Studio creates a new sakila folder inside the project, which contains all the tables mapped to entities and the sakilaContext.cs file.
Even though the Oracle instructions said that Microsoft.EntityFrameworkCore.Tools was not needed for EF Core 2.1 I installed the version 2.2.0 that is compatible with EF 2.2
Update EF Core tools using dotnet CLI or Package Manager Console or visiting
this site https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools/2.1.2
Or you may ignore this. It's not a big issue...
In your application, Dot.net core library version is 2.1.2 and you are working on 2.1.1 of Entity framework core(2.1.1).
So, Update your library version which should be equal to dot.net core version (2.1.2).
I got this error multiple times my packages was up to date in NuGet package manager
So I modified (.csproj) with note pad to the desired version and it solved my problem.

NuGet Package Manager Console Command Fails But Search -> Install Works

I was just installing a new package thats not in my local cache. I took the command directly from the NuGet site.
Executing the command in the PMC failed with the following error:
The source at All [(Aggregate source)] is unreachable. Falling back to NuGet Local Cache at C:\Users\Jammer\AppData\Local\NuGet\Cache
Install-Package : Unable to find package 'Xam.Plugins.Settings'.
At line:1 char:16
+ Install-Package <<<< Xam.Plugins.Settings
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
I've confirmed all the settings are correct, all the usual NuGet source URLs are present and correct as expected. I have NuGet 2.8.5 installed.
When I searched using the "Manage Packages for Solution" option within Visual Studio it found the package I was after and installed it all as expected.
Has anyone seen this and have an idea as to what is going on here?
Ahhh, OK> Solved this immediately.
I uninstalled the package from within the solution
Removed the package from the NuGet local cache
Then on the command line I did this
cd C:\Users\username\AppData\Local\NuGet
nuget.exe update -self
Turns out that the version of NuGet required for the package is stated as 2.8.1, the version in the cache was 2.8.3 so should have been fine but an update to 2.8.5 fixed the issue I was having with Package Manager Console.
I was having the same problem, although no C:\Users\username\AppData\Local\NuGet folder existed.
My version is 2.8.60318.667, I downloaded and installed it but I couldn't install any package.
The solution is in Tools > Nuget Package Manager > Package Manager Settings.
Click on the Package Sources branch, and check 'nuget.org' as Available package sources.
Now it works fine.
Best Regards,

Nuget install fails for pre-release package with dependencies

I have two pre-release nuget packages A.nuget and B.nuget, and B depends on A.
Install A.nuget works:
nuget.exe install A -Source E:\out\packages -OutputDirectory e:\NugetCache -Prerelease -PackageSaveMode nuspec;nupkg
Installing B.nuget fails:
nuget.exe install B -Source E:\out\packages -OutputDirectory e:\NugetCache -Prerelease -PackageSaveMode nuspec;nupkg
Unable to resolve dependency 'A.1.0.0.196-moma159241025'
I double checked and A.1.0.0.196-moma159241025 is installed under e:\NugetCache.
How can I resolve this error?
The work-around I use to solve this uses the -IgnoreDependencies switch, meaning the chosen package will install without its dependencies, regardless of whether Nuget can find them or not.
Install all packages "B" depends on (including "A")
Install package "B" using the -IgnoreDependencies switch
Install-Package A -IncludePrerelease
Install-Package SomeDependencyFromB
Install-Package SomeOtherDependencyFromB
Install-Package B -IncludePrerelease -IgnoreDependencies
https://docs.nuget.org/consume/package-manager-console-powershell-reference

is there an updated version for Hottowel.angular.breeze -pre install package?

i tried installing this package and got the following error.
Install-Package : Updating 'Microsoft.AspNet.WebApi.OData 5.0.0' to 'Microsoft.AspNet.WebApi.OData 4.0.30506' failed. Unable to find a version of 'Breeze.Server.WebApi2' that is compatible with
'Microsoft.AspNet.WebApi.OData 4.0.30506'.
At line:1 char:1
+ Install-Package HotTowel.Angular.Breeze -Pre
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
any help is appreciated,
thanks
Thanks for watching my course! Some of you have let me know that there are some issues with the newest WebApi NuGet packages. Once these are resolved (coordinating with Microsoft and Breeze folks) I will let you all know. In the meantime, here is the workaround which is quite simple:
For now, the easiest thing to do is install the nuget packages in this order. I am working with the Breeze team and the ASP.NET team to make this easier soon :)
Install-Package Microsoft.AspNet.WebApi -version 4.0.30506.0
Install-Package Microsoft.AspNet.WebApi.Odata -version 4.0.30506.0
Install-Package EntityFramework.SqlServerCompact -version 4.3.6
install-Package HotTowel.angular -pre
Install-Package HotTowel.angular.breeze -pre
The first 3 ask it to use the WebApi 4.0.30506 ... which makes it all work. Once I get confirmation from the Breeze team on some changes and check them with the Web Api team, I will update this and let everyone know how to make it work with Web API v2.
Thanks again for your support!
UPDATE
You can now use EF6, Web API v2 with Breeze 1.4.5. Just install HotTowel.
Install-Package HotTowel.Angular.Breeze -pre

How can I keep nuget from updating dependencies?

I'm attempting to install a nuget package which has incorrectly specified one of it's dependencies. Common.Logging.Log4Net requires log4net = 1.2.10 however the nuget package specifies log4net >= 1.2.10. Even if I manually install the older version of log4net, nuget upgrades log4net to 1.2.11 when I install Common.Logging.Log4Net. How can I get nuget to bypass dependency resolution or at least prefer installed packages of a sufficient version?
In order to bypass dependency resolution you can use the -IgnoreDependencies option:
Install-Package -IgnoreDependencies ThePackageName
You should be able to lock the package to a specific version by hand-editing the packages.config and setting the allowedVersions attribute to indicate the version span you want to allow.
<package id="Common.Logging.Log4Net" version="1.2.10"
allowedVersions="[1.2,1.2.10]" />
Note that his will however not upgrade the version of the package at all even when explicitly updating the package.
See the nuget versioning documentation for more info on versioning.