Project targets ‘net6.0’. It cannot be referenced by a project that targets ‘.NETFramework,Version=v6.0’.

Steve Ellwood
Feb 5, 2022

--

While I was upgrading some of my libraries from .net core 3.1 to .net 6.0 I got this error

C:\Program Files\dotnet\sdk\3.1.302\Microsoft.Common.CurrentVersion.targets(1655,5): error : Project 'MyProject.csproj' targets 'net6.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v6.0'. [c:\MyProject.csproj]

At first this really threw me as .Net Framework 6.0 didn’t exist at the time of writing. When I looked closer I realised that this was coming from the 3.1.302 sdk which gave me the clue I needed. These project had a global.json file

{
"sdk": {
"version": "3.1.302",
"rollForward": "latestPatch",
"allowPrerelease": false
}
}

All I needed to do was change the version element to

     "version": "6.0.100",

which allows the project to use the .net 6 tooling.

--

--

Steve Ellwood
Steve Ellwood

Written by Steve Ellwood

Senior Integrations Officer at Doncaster Council Any views expressed are entirely my own.