Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Your project is not referencing the ".NETFramework,Version=v4.5" framework.

I am using VS 2015.

Your project is not referencing the ".NETFramework,Version=4.5" framework. Add a reference to ".NETFramework,Version=4.5" in the "frameworks" section of your project.json, and then re-run NuGet restore.

I am getting this error on my Data Access and Business Logic layers, shortly after adding to my MVC Layer. Things were building fine until then, but I don't know what triggered this error. Here is my project.json:

{   "version": "1.0.0-*",   "description": "foo bar Class Library",   "authors": [ "foo bar" ],   "tags": [ "" ],   "projectUrl": "",   "licenseUrl": "",    "frameworks": {     "net451": { },     "dotnet5.4": {       "dependencies": {         "Microsoft.CSharp": "4.0.1-beta-23516",         "System.Collections": "4.0.11-beta-23516",         "System.Linq": "4.0.1-beta-23516",         "System.Runtime": "4.0.21-beta-23516",         "System.Threading": "4.0.11-beta-23516"       }     }   } } 

Here's what I have tried:

  1. Replacing "dotnet5.4" with "net451" (and deleting it) as found in this answer.

Result is the same error.

  1. Replacing "dotnet5.4" with "net45" and leaving the "net451". This results in a new error:

Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win":{} }' to your project.json and then re-run NuGet restore.

I tried doing as this error suggested and adding

"runtimes": {     "win":  {}   }, 

This got me this error, which I can't seem to move past:

Your project.json doesn't list 'win' as a targeted runtime. You should add '"win": {}' inside your "runtimes" section in your project.json, and then re-run NuGet restore.

I've already added "win", and this is beginning to feel like a red herring. What am I doing altering the project.json directly, isn't NuGet handling this?

like image 220
S. Loveland ECY Avatar asked Mar 23 '16 23:03

S. Loveland ECY


Video Answer


1 Answers

I had this same problem, and I ended up having to not only delete the contents of bin and obj folders, but also the .vs directory for the solution.

like image 113
Chris R. Donnelly Avatar answered Oct 24 '22 03:10

Chris R. Donnelly