How do I reference a .NET Framework project in a .NET Core project?

Old question, but with the release of .NetStandard 2.0 and .netcore 2.0 and vs2017.3, the game has changed.

You can use the Full .NET Framework (TFM) with .NetCore 2.0, but how?

  1. In Visual Studio 2017.3, you can reference the Full .NET Framework (any version) directly from within a .NetCore2 project.

  2. You can build the .NetStandard2 class library and reference your TFM. Then reference your .NetStandard2 library from your .NetCore2 project.

For example, referencing json.net net45 from .NetStandard2.
Browse to the folder and select version net45 (not netstandard1.3)

See the dependency in the image below, no yellow warning as you see.

enter image description here

  1. Even if a Nuget library is not ready to be ported to .Netstandard 2, you can use any API in the library that is compliant to net461.

Quoting for the .NET Core 2/Standard 2.0 announcement with links:

.NET Core 2.0 is able to freely reference libraries that have been built for .NET Framework up to version 4.6.1

However, some libraries may fail at run time if they try to use API methods that aren’t available on .NET Core

Reference: .NET Core App target .NET framework 4.5.2 on Linux

A need to use third-party .NET libraries or NuGet packages not available for .NET Core

So only in cases where the libraries or NuGet packages use technologies that aren’t available in .NET Standard/.NET Core, you need to use the .NET Framework.

Reference: Choosing between .NET Core and .NET Framework for server apps

You can now reference .NET Framework libraries from .NET Standard libraries using Visual Studio 2017 15.3. This feature helps you migrate .NET Framework code to .NET Standard or .NET Core over time (start with binaries and then move to source). It is also useful in the case that the source code is no longer accessible or is lost for a .NET Framework library, enabling it to be still be used in new scenarios.

Reference: Announcing .NET Core 2.0

Leave a Comment