sdk: Failed to create prime the NuGet cache. restore failed with: 1
Steps to reproduce
dotnet restore
Expected behavior
Successfully finished.
Actual behavior
Failed to create prime the NuGet cache. restore failed with: 1 Restoring packages for /home/chenzheyou/hwapp/hwapp.csproj… /usr/share/dotnet/sdk/1.0.4/NuGet.targets(97,5): error : An error occurred while retrieving package metadata for ‘Libuv.1.9.1’ from source ‘/home/chenzheyou/.nuget/packages/’. [/home/chenzheyou/hwapp/hwapp.csproj] /usr/share/dotnet/sdk/1.0.4/NuGet.targets(97,5): error : Root element is missing. [/home/chenzheyou/hwapp/hwapp.csproj]
Environment data
dotnet --info output:
.NET Command Line Tools (1.0.4)
Product Information: Version: 1.0.4 Commit SHA-1 hash: af1e6684fd
Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64 Base Path: /usr/share/dotnet/sdk/1.0.4
Note
Ubuntu is run under VM Player
About this issue
- Original URL
 - State: closed
 - Created 7 years ago
 - Reactions: 1
 - Comments: 15 (3 by maintainers)
 
This is a known issue with 1.0.4 installed side-by-side with a 2.0 SDK. I would recommend temporarily removing the 2.0 SDK, running the first run for 1.0.4 and then putting 2.0 back. This happens because as part of the first run experience, we shell out to dotnet to invoke dotnet new -f netcoreapp1.0. With 2.0 on the path, the 2.0 SDK gets picked to run this command, but it does not have a template for that TFM, and so it fails.
We have fixed that in the 1.1.0-preview1 SDK, in which we make sure that dotnet new is shelled out to the same SDK that triggered the first run experience. And in the 2.0 SDK, we remove this entirelly, and all we do is expand the offline cache, so that it is simpler and faster.
Sorry for the inconvenience. I am going to keep this issue closed since it has also been ported to the 1.0 SDK, we just haven’t had an official release of it yet.
Clearing all of the local nugget caches did not fix the issue for me.
I started getting this error after targeting an older version of the .net core SDK (1.0.4) using the global.json file. I have multiple versions of the .net core SDK on my machine
For me the solution was to update the .NET Core SDK version in global.json from 1.0.0-rc4-004771 to 2.0.0.
i cleared nuget cache by run “dotnet nuget locals -c all”, and made it succeed after restoring again. thank you @emgarten @livarcocc