System could not be found Visual Studio 2017 ASP.NET Core project

I've installed the newly released version of Visual Studio 2017 and started a fresh ASP.NET Core project targeting .NET Core.

Out of the box, I'm getting the

The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)

error. Any idea what's causing this and how to fix it?

enter image description here

Also, looks like there are problems with NuGet packages as well: enter image description here

I also tried dotnet restore on the project through the command line and got the following error: enter image description here

P.S. Kind of disheartening that you get an error in a fresh new project in the latest version of Visual Studio 2017!

UPDATE: SDK version is v 1.0.1 -- see below: enter image description here

UPDATE 2: This is very strange. Looks like the original problem was due to NuGet package source pointing to a folder under Visual Studio 2015 folder. I unchecked it and left only nuget.org. With that my project seemed to have restored all the packages and when I started the project it loads up the standard ASP.NET page. But if I open startup.cs file, I get red squigglies all over the place but if I run the project, it works fine. What's going on here? enter image description here

UPDATE 3: I closed the project and VS 2017. I then restarted VS 2017 and opened the project and now it seems to be fine. And I'm not referencing the .NETStandard library 1.6.1 and everything seems to be working fine now.


Solution 1:

I had the same issue in my Visual studio 2017 .Net Core application. I closed the Visual studio and re-open fixed everything.

Solution 2:

Came across the same issue today. I had an old nuget source that no longer existed. So I went into Tools > Nuget Packet Manager and un-checked the wrong one. Hit "Ok", and then rebuilt the project, and it works great now. It seems like you stumbled onto it, but also wanted to verify that it fixed my issue, and it does.

enter image description here

Solution 3:

I had the same problem, first when converting a VS2015 net core mvc web project to 2017 and then when trying to create a new core web application in 2017.

Went to Tools|NuGet Package Manager|Package Manager Settings - checked 'Allow NuGet to download missing packages' and 'Automatically check for missing packages during build in VS' and then clicked 'Clear All NuGet Cache(s)'.

Then re-built the solution - it found and loaded all the required packages and ran OK.

May not work for all cases but simple and worth a try.

Solution 4:

Multiple closing and reopening of VS2017 fixed it for me.

Solution 5:

I had the same issue, the solution for me was to clear the NuGet cache. Tools > NuGet Package Manager > Package Manager Settings > Clear All NuGet Cache(s)