1
votes

I recently included a .net 4.6.2 project to use with my .net core 2.1 app. But after I've done this the projects stopped to compile throwing this error:

Error Your project does not reference ".NETFramework,Version=v4.6.2" framework. Add a reference to ".NETFramework,Version=v4.6.2" in the "TargetFrameworks" property of your project file and then re-run NuGet restore. SelfSignCertificateAssistant

The project stopped to compile even for another pure 4.6.2 solution. Needless to say it was working just fine before.

There was absolutely nothing that was changed in the project, so I'm not sure how to fix this:

enter image description here

2
Did you run nuget restore after setting the target framework?Ron Beyer
That error message promises too much. You can't use a .NETFramework assembly in a .NETCore project. It has to be rebuilt to target either .NETCore or .NETStandard.Hans Passant

2 Answers

3
votes

As i figured in most cases solution proposed by @Chris should work. But for some unknown reason my Visual Studio just refused to compile it throwing the same error. I tried to re-download the project, re-reference frameworks, restarting VS...

What helped me is physically deleting project folder and then re-downloading it from source control. After this was done i was able to successfully compile it. Not sure what was the problem though.

2
votes

In Visual Studio go to Tools > Options... and in the left pane, scroll down and select Nuget Package Manager. Then, check the boxes under General that say "Allow nuget to download missing packages" and "Automatically check for missing packages during build in Visual Studio".

Once you do that, try rebuilding your project and nuget should then restore any missing packages for your project.