Nuget package is not compatible, but in the supported-list (StrawberryShake.Tools) - nuget

I got this message after creating a new .NET 5-project (in VS2019) and trying to install nuget-package StrawberryShake.Tools. This seems a bit strange, since it says both that it is and it isnt compatible with "net5.0 (.NETCoreApp,Version=v5.0)"
Error NU1202 Package StrawberryShake.Tools 12.6.0 is not compatible
with net5.0 (.NETCoreApp,Version=v5.0). Package StrawberryShake.Tools
12.6.0 supports:
net5.0 (.NETCoreApp,Version=v5.0) / any
net6.0 (.NETCoreApp,Version=v6.0) / any
netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any

I had the same problem, so I followed the official installation guide instead. The steps are as follows:
Open a terminal and navigate to e.g. the project where you want the package to be installed.
Run dotnet new tool-manifest.
Run dotnet tool install StrawberryShake.Tools --local. The nuget package has now been installed in ~/.nuget/packages and may be used in the project.

Related

Why can't I install Microsoft.EntityFrameworkCore.Sqlite?

I am following this tutorial:
https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=visual-studio
I am immediately stopped because I can not complete the following command:
Install-Package Microsoft.EntityFrameworkCore.Sqlite
This is the error:
Could not install package 'Microsoft.EntityFrameworkCore.Sqlite.Core 7.0.0'. You are trying to install a package into a project that targets '.NETFramework,Version=v4.7.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 am attempting to learn how to use the Entity Framework and so I don't know much regarding this. Any advice would be helpful even if it's a link to something I need to read.
About the tutorial
The tutorial is about .netCore but in the error message you can see that you created a .netFramework project '.NETFramework,Version=v4.7.2'.
Create a new console application, but don't select projects that have (.NET Framework) in the description.
About the Sqlite package (only if continue the practicing with .netFramework)
The command Install-Package Microsoft.EntityFrameworkCore.Sqlite will try to install the last version. Currently, the last version is 7.0.0. This version only work with .NET 6.0.
You can check existing .net versions right here
So, you need to specify the version. The version for .NET 4.7.2 is the 3.1.31.
Install-Package Microsoft.EntityFrameworkCore.Sqlite -Version 3.1.31
Nuget Sqlite package info here

Dotnet restore not working

dotnet Version: 1.1.0 (global.json)
NuGet Version : 4.4.1.4656
VS2017 v15.5.2 (as Administrator)
.NET Core 1.1
The solution I am trying to build
Update I:
I just changed the project to run under target framework .NET Core v2.0 & sdk version 2.1.3 and I only get these kind of errors:
Severity Code Description Project File Line Suppression State
Error NU1202 Package Microsoft.Extensions.FileProviders.Physical 1.1.0
is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0).
Package Microsoft.Extensions.FileProviders.Physical 1.1.0 does not
support any target
frameworks. AspNetCoreExample C:\Users\Admin\Source\Repos\Examples\src\AspNetCoreExample\AspNetCoreExample.csproj 1
Update II:
While the following solves the current issue, i am not sure if it solves the root cause for this issue.
Delete the global nuget.config file %AppData%/Nuget/Nuget.config.
I fixed this issue by doing the following:
I migrated the project to .net core 2.0 and changed the global.json to point to sdk 2.1.3.
Removed all references in AspNetCoreExample manually and added the latest version for all of them.
Issues with target framework 1.1
When doing a restore from the solution in VS 2017:
When doing the restore from cmd (dotnet restore)
Running dotnet restore in Package Manager Console
NuGet.targets(103,5): error : Access to the path 'System.Runtime.dll'
is denied
.NET Core SDKs installed:
.NET Host
Now when opening the solution I get:
Comparing the log entries you pasted to their AppVeyor build,
https://ci.appveyor.com/project/Autofac/examples
Your machine's NuGet configuration seems to be broken. Analyze that and fix the issues.
You should add this code to your .csproj file
<RuntimeFramework>2.0.3</RuntimeFramework>
This worked for me.

Unable to resolve dependencies. 'xxx' is not compatible with 'yyy constraint: zzz)'

We have a project that is utilizing a set of Nuget-based Azure libraries. One of them was published with a specific MIN and MAX dependency on Newtonsoft.Json (max version being 7)
This was a headache, because other libraries depend on 8+ version of Netwon and this specific Azure library is just fine working with any modern Json package.
In VS2013, we forced to install this Azure library with newer version of Json package thru nuget installer and subsequently, Nuget never gave us any issues installing/updating other libraries.
However, after upgrading to VS2017, we cannot update any package (or at least the ones that depend on Json) and we get the error below.
Unable to resolve dependencies. 'Newtonsoft.Json 8.0.3' is not compatible with 'Microsoft.Azure.Insights 0.15.0-preview constraint: Newtonsoft.Json (>= 6.0.8 && < 7.0.0)'
How do we have Nuget ignore that specific Azure library's unimportant MAX version dependence?
How do we have Nuget ignore that specific Azure library's unimportant MAX version dependence?
If you confirm that Azure library is just fine working with any modern Json package and you want use the Microsoft.Azure.Insights 0.15.0-preview and 8+ version of Newtonsoft.Json at the same time. I would like provide a workaround to you, hope this can help you.
Detailed Steps:
Install the package Microsoft.Azure.Insights 0.15.0-preview with its dependencies first.
Only uninstall the package Microsoft.Azure.Insights 0.15.0-preview, Keep dependencies installed.
Update the Newtonsoft.Json to the version 8+.
Install the package Microsoft.Azure.Insights 0.15.0-preview in the Package Manager Console with following NuGet command:
Install-package Microsoft.Azure.Insights -IncludePrerelease -IgnoreDependencies
With the option -IgnoreDependencies, NuGet will ignore that specific Azure library's unimportant MAX version dependence:
Note: Need to mention is that if you update the Newtonsoft.Json package next time, you still need to follow the steps above to upgrade your Newtonsoft.Json package.

Cannot install FsLab with NuGet

Complete VS noob. Fresh install of Visual Studio Community 2015. New project. Trying to install FsLab with NuGet ends with this error:
Unable to find a version of 'Deedle' that is compatible with 'FsLab 1.0.2 constraint: Deedle (= 1.2.5)'
When I search for Deedle the version that NuGet shows is v1.2.5.
I suspect this is a NuGet problem after reading about some issues with its dependency resolution management.
I tried installing Deedle separately and setting NuGet's Dependency behavior to Highest with no luck. In the end I installed Paket which worked with no problems. No time to debug this further for now.

How can I install an older version of a package via NuGet?

I want to install an older version of a package (Newtonsoft.Json). But NuGet rolls back:
PM> Install-Package Newtonsoft.Json -Version 4.0.5
Successfully installed 'Newtonsoft.Json 4.0.5'.
Install failed. Rolling back...
Install-Package : Already referencing a newer version of 'Newtonsoft.Json'.
How can I do it?
Try the following:
Uninstall-Package Newtonsoft.Json -Force
Followed by:
Install-Package Newtonsoft.Json -Version <press tab key for autocomplete>
As of NuGet 2.8, there is a feature to downgrade a package.
NuGet 2.8 Release Notes
Example:
The following command entered into the Package Manager Console will downgrade the Couchbase client to version 1.3.1.0.
Update-Package CouchbaseNetClient -Version 1.3.1.0
Result:
Updating 'CouchbaseNetClient' from version '1.3.3' to '1.3.1.0' in project [project name].
Removing 'CouchbaseNetClient 1.3.3' from [project name].
Successfully removed 'CouchbaseNetClient 1.3.3' from [project name].
Something to note as per crimbo below:
This approach doesn't work for downgrading from one prerelease version to other prerelease version - it only works for downgrading to a release version
I've used Xavier's answer quite a bit. I want to add that restricting the package version to a specified range is easy and useful in the latest versions of NuGet.
For example, if you never want Newtonsoft.Json to be updated past version 3.x.x in your project, change the corresponding package element in your packages.config file to look like this:
<package id="Newtonsoft.Json" version="3.5.8" allowedVersions="[3.0, 4.0)" targetFramework="net40" />
Notice the allowedVersions attribute. This will limit the version of that package to versions between 3.0 (inclusive) and 4.0 (exclusive). Then, when you do an Update-Package on the whole solution, you don't need to worry about that particular package being updated past version 3.x.x.
The documentation for this functionality is here.
Now, it's very much simplified in Visual Studio 2015 and later. You can do downgrade / upgrade within the User interface itself, without executing commands in the Package Manager Console.
Right click on your project and *go to Manage NuGet Packages.
Look at the below image.
Select your Package and Choose the Version, which you wanted to install.
Very very simple, isn't it? :)
Another more manual option to get it:
.nuget\nuget.exe install Newtonsoft.Json -Version 4.0.5