VSTS构建:软件包无法恢复 - 无法为".NETStandard,Version = v2.0"解析"NETStandard.Library(> = 1.6.1)"

Lie*_*ero 20 .net-core azure-devops azure-pipelines .net-core-2.0 .net-standard-2.0

我越来越

无法为'.NETStandard,Version = v2.0'解析'NETStandard.Library(> = 1.6.1)'.

在我将aspnetcore应用程序升级到netcoreapp2.0我的库并使用之后,使用Hosted2017构建代理构建VSTS netstandard2.0.

在当地工作正常.

我编辑了我的构建定义以使用.net核心构建任务v2.* preview:

构建定义细节

这是构建日志:

Current agent version: '2.120.2'
Download all required tasks.
Downloading task: DotNetCoreCLI

Starting: Get Sources
Syncing repository: Liero/vyvojari-sk (GitHub)
...details ommited
HEAD is now at e448a25... Upgraded to .NET Core 2.0
Finishing: Get Sources

Starting: Restore
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
Version      : 2.0.5
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
==============================================================================
SYSTEMVSSCONNECTION exists true
Downloading: https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe
Caching tool: NuGet 4.0.0 x64
Using version: 4.0.0
Found tool in cache: NuGet 4.0.0 x64
Saving NuGet.config to a temporary config file.
Can\'t find loc string for key: NGCommon_NoSourcesFoundInConfig
NGCommon_NoSourcesFoundInConfig d:\a\1\Nuget\tempNuGet_734.config
"C:\Program Files\dotnet\dotnet.exe" restore d:\a\1\s\src\CommandStack\CommandStack.csproj --configfile d:\a\1\Nuget\tempNuGet_734.config --verbosity Detailed
  Restoring packages for d:\a\1\s\src\CommandStack\CommandStack.csproj...
C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'. [d:\a\1\s\src\CommandStack\CommandStack.csproj]
  Generating MSBuild file d:\a\1\s\src\CommandStack\obj\CommandStack.csproj.nuget.g.props.
  Generating MSBuild file d:\a\1\s\src\CommandStack\obj\CommandStack.csproj.nuget.g.targets.
  Writing lock file to disk. Path: d:\a\1\s\src\CommandStack\obj\project.assets.json
  Restore failed in 115.64 ms for d:\a\1\s\src\CommandStack\CommandStack.csproj.

  Errors in d:\a\1\s\src\CommandStack\CommandStack.csproj
      Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'.

  NuGet Config files used:
      d:\a\1\Nuget\tempNuGet_734.config
Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
Packages failed to restore
******************************************************************************
Finishing: Restore
******************************************************************************
Run Code Online (Sandbox Code Playgroud)

这是源代码:https://github.com/Liero/vyvojari-sk/tree/e448a25fb8c481704e9102aaaeb8b84b9aee7b02

Chr*_*ton 61

2017年9月18日更新

不再需要第2步.我把它留在了解决方案中,因为它可能仍然可以帮助一些人.谢谢,@ Liero指出了这一点.


原始答案

我刚刚遇到了这个问题并通过做三件事解决了这个问题:

  1. 使用.NET Core SDK(! - not runtime!)版本2.0.0: 在此输入图像描述

  2. 使用最新的NuGet feed(4.3.0): 在此输入图像描述

  3. 恢复你的包裹: 在此输入图像描述

更新 此处值得一提的是,您应该指定从哪里获取NuGet包.根据屏幕截图(参见小复选框),大多数应用程序可能只使用NuGet.org提要,但您可以在NuGet.config文件中指定自定义提要.在这种情况下,勾选'在NuGet.config中输入',然后指定该文件的路径.

为了说明顺序,这是我的工作队列: 在此输入图像描述

我希望这可以帮助你和其他任何反对这个问题的人.如果您有任何疑问,请告诉我.:)