core icon indicating copy to clipboard operation
core copied to clipboard

.Net Core v2.0 - Nuget Packages are not getting restored

Open Zeshan-Munir opened this issue 9 years ago • 17 comments

.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:

  1. Visual Studio 2017 v15.3 Using New Project, default templates, they don't get built because nuget packages are not restored
  2. CLI Tried to make new apps using commands, and the nuget package restore failed. After that tried to use DotNet Restore, that returned the same results.

What I have tried:

  1. Checked on CLI that DotNet --Version returns 2.0.0
  2. Repaired Visual Studio.

Zeshan-Munir avatar Oct 03 '17 09:10 Zeshan-Munir

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)

Zeshan-Munir avatar Oct 03 '17 09:10 Zeshan-Munir

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).

philippgille avatar Oct 03 '17 12:10 philippgille

@the-super-coder can you share what your project looks like?

/cc @rrelyea

Petermarcu avatar Oct 05 '17 02:10 Petermarcu

@emgarten

Petermarcu avatar Oct 06 '17 22:10 Petermarcu

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).
image

gkingston avatar Oct 07 '17 01:10 gkingston

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?

Petermarcu avatar Oct 07 '17 02:10 Petermarcu

Says the Restore completed, then the dotnet run fails in the same way though image

I've also done a full uninstall of the sdk 2 and reinstall vs just a repair

gkingston avatar Oct 07 '17 02:10 gkingston

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.

Petermarcu avatar Oct 07 '17 02:10 Petermarcu

Thanks, deleting the C:\Program Files\dotnet\sdk\NuGetFallbackFolder (and deleting obj/bin folders of existing projects) fixed it for me.

gkingston avatar Oct 07 '17 03:10 gkingston

Awesome! Glad it worked.

Petermarcu avatar Oct 07 '17 03:10 Petermarcu

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.

Petermarcu avatar Oct 07 '17 03:10 Petermarcu

@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

Zeshan-Munir avatar Oct 09 '17 17:10 Zeshan-Munir

Thanks I deleted the "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" which fixed the issue.

Zeshan-Munir avatar Oct 09 '17 17:10 Zeshan-Munir

Thanks all!!!

alexsandro-xpt avatar Jun 21 '19 14:06 alexsandro-xpt

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.

LosManos avatar Jul 05 '19 11:07 LosManos

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

Nefcanto avatar Dec 24 '19 08:12 Nefcanto

Thanks, deleting the C:\Program Files\dotnet\sdk\NuGetFallbackFolder (and deleting obj/bin folders of existing projects) fixed it for me.

I only deleted obj/bin folders and that fixed it

PersyJack avatar Apr 21 '20 21:04 PersyJack