Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the best way to find out if a nuget package is compatible with .net core without nuget.org?

I know nuget.org does not have this functionality yet, but I have been searching for release notes on the nuget package developer websites, and this is taking longer than expected, since I have a lot of nuget packages installed on my .net framework project. Is there a better way to do this? maybe someone has already done it and posted a list somewhere?

thanks in advance

like image 662
Jovemsincero Avatar asked Nov 08 '18 10:11

Jovemsincero


People also ask

Is my NuGet package compatible with the target frameworks?

As part of our ongoing commitment to improve the NuGet ecosystem, today we are excited to introduce a couple new features on NuGet.org to help you determine if a package is compatible with the target frameworks you know and love. This is how it looks: You will now have a new “Frameworks” tab on any package details page.

Is there a way to view which package source an installed NuGet?

Is there a way to view which package source an installed NuGet package is from, in Visual Studio? The simple answer is No. That is because the information about which NuGet packages have been installed in a solution by in the "Installed" tab in the package manager is based on the packages.config file.

When should I use NuGet?

When starting any .NET project, or whenever you identify a functional need for your app or service, you can save yourself lots of time and trouble by using existing NuGet packages that fulfill that need. These packages can come from the public collection on nuget.org, or a private source that's provided by your organization or another third party.

Does NuGet support native C++ packages?

NuGet supports native C++ packages can that can be used in C++ projects in Visual Studio. This enables the Manage NuGet Packages context-menu command for projects, introduces a native target framework, and provides MSBuild integration. To find native packages on nuget.org, search using tag:native.


2 Answers

If you change the 'n' in the nuget URL to an 'f', so it becomes fuget, you'll get a list of which frameworks the package targets. If you see it targets a netstandard version then it will work with .NET Core.

like image 185
sedders123 Avatar answered Oct 20 '22 17:10

sedders123


If your project is using an "old" style csproj with packages.config, the first step is to migrate to using PackageReference instead. Here's some docs. As the docs say, there are some differences between how packages.config and PackageReference works. If you're affected, you're blocked until you can make your project work with PackageReference.

If your project is using an "old" style csproj with PackageReference (for example you did the migration above), then migrate to SDK-based csproj so you can build with the dotnet CLI. Here's a blog post with details how to do it.. Note you you can keep using the Windows .NET Framework with SDK csproj. Although SDK-based csproj came out at the same time as .NET Core, it's not necessary to use .NET Core with the new project style. If your project is a class library or console app, you're definitely fine, otherwise you need to research to find out if the project type is compatible with SDK projects or not.

Once you have your .NET Framework project working with SDK projects, either change the TargetFramework to netcoreapp or netstandard, or you can multi-target your project by changing TargetFramework to TargetFrameworks, and use a semi-colon separated list of TFMs you want to target. For example <TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>. Then simply run dotnet restore and if any of the packages you use is not compatible with .NET Core, restore will fail, and you simply revert to target only .NET Framework.

In summary, once your project uses SDK-based csproj, it takes 10 seconds to test if your dependencies are compatible with .NET Standard/.NET Core. If your project is not yet using SDK-based csproj, you undo your change to the TargetFramework(s) line in your csproj and continue with your life until the next time you test again. If you're not already on SDK-based csproj and there's nothing blocking you from doing so, then doing the upgrade is low risk and bring some benefits, such as fewer merge conflicts on the file, much easier to create nupkgs for any packages you maintain, and being able to test against .NET Core compatibility in seconds.

Alternative: If you're unable or unwilling to migrate to SDK-based projects and you want to check if your dependencies are compatible, then use dotnet new classlib to create a new .NET Core project, add package references to the same packages that your existing project uses, then try to restore. If you have a big solution with lots of projects and/or references, just write a small program to read your packages.config/csproj files as XML, find unique list of packages that you use, then write a new SDK-based csproj targeting .NET Core with all the packages you just found as package references.

like image 43
zivkan Avatar answered Oct 20 '22 18:10

zivkan