C# 无法创建NuGet缓存、dotnet还原。

C# 无法创建NuGet缓存、dotnet还原。,c#,.net-core,C#,.net Core,我正在VS2017中编写应用程序.Net Core。 使用dotnet restore命令时,我收到一条消息 Configuring... ------------------- A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minu

我正在VS2017中编写应用程序.Net Core。 使用dotnet restore命令时,我收到一条消息

    Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 100% 4774 ms
Expanding 100% 12241 ms
Failed to create prime the NuGet cache. restore failed with: 1
  Restoring packages for D:\01_Toci\100_GIT\Passenger\Passenger.Api\Passenger.Api.csproj...
  Restoring packages for D:\01_Toci\100_GIT\Passenger\Passenger.Infrastructure\Passenger.Infrastructure.csproj...
  Restoring packages for D:\01_Toci\100_GIT\Passenger\Passenger.Core\Passenger.Core.csproj...
  Lock file has not changed. Skipping lock file write. Path: D:\01_Toci\100_GIT\Passenger\Passenger.Infrastructure\obj\project.assets.json
  Lock file has not changed. Skipping lock file write. Path: D:\01_Toci\100_GIT\Passenger\Passenger.Core\obj\project.assets.json
  Restore completed in 337,41 ms for D:\01_Toci\100_GIT\Passenger\Passenger.Core\Passenger.Core.csproj.
  Restore completed in 337,39 ms for D:\01_Toci\100_GIT\Passenger\Passenger.Infrastructure\Passenger.Infrastructure.csproj.
  Lock file has not changed. Skipping lock file write. Path: D:\01_Toci\100_GIT\Passenger\Passenger.Api\obj\project.assets.json
  Restore completed in 1,34 sec for D:\01_Toci\100_GIT\Passenger\Passenger.Api\Passenger.Api.csproj.

  NuGet Config files used:
      C:\Users\wojse\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

  Feeds used:
      https://api.nuget.org/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
dotnet--信息输出:

D:\01_Toci\100_GIT\Passenger\Passenger.Api>dotnet --info
.NET Command Line Tools (1.0.4)

Product Information:
 Version:            1.0.4
 Commit SHA-1 hash:  af1e6684fd

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.4

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.3
  Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df
我尝试了很多方法,但都没有任何效果:

  • 我安装了.NETCore2.0
  • 我将包变量更改为:1.0.4in.csproj
  • 在dotnetrestore之后,我使用了命令dotnetnugetlocals-c all

有人能帮我吗?:)请

这是.NET Core SDK的1.0.*版本(非运行时!)的一个问题,该版本一旦设置了全局回退文件夹,就不再与较新NuGet版本中引入的功能兼容


因为您似乎安装了2.0版本,所以可能有一个
global.json
文件固定了旧版本的SDK。确保您锁定了SDK的1.1.*或2.*版本,或者根本不使用
global.json
文件。您仍然可以使用较新的SDK以.NET Core 1.0为目标。

升级到VS 15.6后,我遇到了这个问题。我可以暂时将所有比1.0.4更新的SDK移出SDK文件夹(C:/Program Files/dotnet/SDK),从而绕过这个问题。运行dotnet restore,缓存填充成功,然后将SDK移回


从长远来看,我们将更新global.json文件,以锁定一个更新的SDK,正如前面的响应所示。

我能够通过编辑global.json并替换以下内容来解决此问题:

"version": "1.0.0-rc4-004771"
与:


请参阅:Jon Skeet在他对这个问题的评论中提到了这个问题。

也许是相关的?或者?在安装2.1.400I之后,这对我在Ubuntu 16.04上的工作是有效的,但我很高兴我找到了这个答案。在Windows-10上为我的工作。
"version": "2.0.0"