S.Chandra Sekhar
S.Chandra Sekhar

Reputation: 503

How to add .NET Core 2.1 project reference in Unit Test project built on .NET Framework 4.6.1

I want to write unit test cases for a project which was built using .net core 2.1.

Unit test project using .net framework 4.6.1.

I am facing below issue while adding .net core app reference in Unit test project.

Project '..\MSNetCoreApp.csproj' targets 'netcoreapp2.1'.It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.1'. MSUnitTests

Upvotes: 1

Views: 230

Answers (1)

Nenad
Nenad

Reputation: 26727

It cannot be done.

Your MSNetCoreApp is compiled to run on .NET Core Framework, while your test project needs to run on full .NET Framework. They are not compatible.

You need to create new test project targeting netcoreapp2.1 or to convert existing one.

Only class libraries targeting netstandard can be referenced by both netcore and netframework assemblies.

Upvotes: 1

Related Questions