.Net Core v2.0 - Nuget Packages are not getting restored
Any application that is targeting .Net Core v2.0 framework, will not build as NugetPackages are not restored successfully. I have tried with both the Console Apps and Web Apps.
Error Messages I am getting:
Restoring NuGet packages...
To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
1>------ Build started: Project: ConsoleApp2, Configuration: Debug Any CPU ------
1>C:\Users\Super.Coder\AppData\Local\Temp.NETCoreApp,Version=v2.0.AssemblyAttributes.cs(4,20,4,26): error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?)
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(14,12,14,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(15,12,15,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(16,12,16,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(17,12,17,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(18,12,18,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(19,12,19,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(20,12,20,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(21,12,21,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\Super.Coder\AppData\Local\Temp.NETCoreApp,Version=v2.0.AssemblyAttributes.cs(4,71,4,97): error CS0518: Predefined type 'System.String' is not defined or imported
1>C:\Users\Super.Coder\AppData\Local\Temp.NETCoreApp,Version=v2.0.AssemblyAttributes.cs(4,99,4,119): error CS0246: The type or namespace name 'FrameworkDisplayName' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\Super.Coder\AppData\Local\Temp.NETCoreApp,Version=v2.0.AssemblyAttributes.cs(4,122,4,124): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(14,55,14,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(15,61,15,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(16,59,16,80): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(17,59,17,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(18,68,18,75): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(19,55,19,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(20,53,20,66): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(21,55,21,64): error CS0518: Predefined type 'System.String' is not defined or imported
1>Program.cs(1,7,1,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\Super.Coder\AppData\Local\Temp.NETCoreApp,Version=v2.0.AssemblyAttributes.cs(2,7,2,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\Super.Coder\AppData\Local\Temp.NETCoreApp,Version=v2.0.AssemblyAttributes.cs(3,7,3,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(11,7,11,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.0\ConsoleApp2.AssemblyInfo.cs(12,7,12,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>Program.cs(5,11,5,18): error CS0518: Predefined type 'System.Object' is not defined or imported
1>Program.cs(7,26,7,32): error CS0518: Predefined type 'System.String' is not defined or imported
1>Program.cs(7,16,7,20): error CS0518: Predefined type 'System.Void' is not defined or imported
1>Done building project "ConsoleApp2.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What tools I have tried with:
What I have tried:
One of the web apps, I got a lot of errors similar to the following:
C:\Users\Super.Coder\source\repos\WebApplication8\WebApplication8\WebApplication8.csproj : error NU1202: Package Microsoft.AspNetCore 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.AspNetCore 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
Tried to make new apps using commands, and the nuget package restore failed.
Which dotnet CLI commands have you tried?
I'm running Windows 10 and have .NET Core SDK 2.0 installed and for me the following works fine (in PowerShell command line window):
> dotnet --version
2.0.0
> mkdir hwapp; cd hwapp
... snip
> dotnet new console
The template "Console Application" was created successfully.
Processing post-creation actions...
... snip
> dotnet run
Hello World!
Where the dotnet new console already contains a dotnet restore (since .NET Core 2.0).
@the-super-coder can you share what your project looks like?
/cc @rrelyea
@emgarten
I'm having the same issue. I can't build from command line or inside VS with just project defaults. I've repaired both the 2.0.0 sdk and VS 2017 with no luck. I am on latest 15.3.5 of VS 2017. This is from just the hello world new console app(dotnet new console -o hwapp).

What happens when you explicitly run dotnet restore?
/cc @rrelyea @emgarten could this be related to the fallback folder or other corruption I've seen in different issues?
Says the Restore completed, then the dotnet run fails in the same way though

I've also done a full uninstall of the sdk 2 and reinstall vs just a repair
Just a guess but maybe you are in this state? https://github.com/dotnet/core/issues/920#issuecomment-327222033. See the workarounds in the next few comments.
Thanks, deleting the C:\Program Files\dotnet\sdk\NuGetFallbackFolder (and deleting obj/bin folders of existing projects) fixed it for me.
Awesome! Glad it worked.
I closed this because I think its another instance of this problem. https://github.com/NuGet/Home/issues/5995. If people continue to see this, go ahead and add more detaild there.
@philippgille Sorry for late response, I was busy with some family work. Well, I am using .Net Core SDK v2.0
@Petermarcu Unfortunately, I cannot expose the personal project. However, I face the same issue with all the default templates for DotNetCore in VS2017 v15.3
Thanks I deleted the "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" which fixed the issue.
Thanks all!!!
My solution was to do a dotnet restore from an elevated command prompt.
(after deleting the NuGetFallbackFolder, but I am not sure that is necessary)
Here is what I did:
Failed compiling with the error of this issue.
Did a dotnet restore and failed with a Permission denied to modify the 'C:\Program Files\dotnet\sdk\NuGetFallbackFolder' folder.
Renamed the NuGetFallbackFolder
Asked VS2019 to do a Package Restore and failed.
Opened an elevated command prompt and dotnet restore. The NuGetFallbackFolder was created.
Asked VS2019 to do a Package Restore and succeeded.
I am not running VS2019 with elevated privileges.
I'm receiving the same set of errors and deleting NuGetFallbackFolder and running dotnet restore did not work for me.
https://github.com/dotnet/core/issues/4040
Thanks, deleting the C:\Program Files\dotnet\sdkNuGetFallbackFolder (and deleting obj/bin folders of existing projects) fixed it for me.
I only deleted obj/bin folders and that fixed it
Most helpful comment
Thanks, deleting the C:\Program Files\dotnet\sdk\NuGetFallbackFolder (and deleting obj/bin folders of existing projects) fixed it for me.