VSTS版本:软件包无法恢复 - 无法解析' NETStandard.Library(> = 1.6.1)' for .NETStandard,Version = v2.0'

时间:2017-08-16 15:13:06

标签: .net-core azure-devops azure-pipelines .net-core-2.0 .net-standard-2.0

我正在

  

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

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

在本地工作正常。

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

build definition details

这是构建日志:

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
******************************************************************************

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

5 个答案:

答案 0 :(得分:61)

2017年9月18日更新

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

原始答案

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

  1. 使用.NET Core SDK(! - 不是运行时!)版本2.0.0: enter image description here

  2. 使用最新的NuGet Feed(4.3.0): enter image description here

  3. 恢复您的套餐: enter image description here

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

    为了说明顺序,这是我的工作队列: enter image description here

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

答案 1 :(得分:4)

您应该选择我选择的Feed 以供使用Feed选项。如果您将使用此VSTS / TFS Feed中的包保留为空,则会从https://dist.nuget.org/下载包。

enter image description here

另外,如果您想使用我的NuGet.config中的Feed 作为要使用的Feed,您应该指定NuGet.config文件的路径。

答案 2 :(得分:1)

使用java.time.*生成项目后,我收到了类似的错误,该项目依赖于dotnet new angular创建了一个项目。检查项目属性显示版本2.0未被正确识别(未出现在已安装的框架列表中)。

解决方案是更新Visual Studio 2017,因为支持 netcoreapp2.0 项目所需的最低版本似乎 15.3.1

答案 3 :(得分:0)

对我有用的是安装.NET Core SDK 2.0并进行以下更改:

在.csproj中:

更改

<TargetFramework>netcoreapp1.1.0</TargetFramework>

<TargetFramework>netcoreapp2.0</TargetFramework>

并在global.json中:

"sdk": { "version": "1.1.0" }

"sdk": { "version": "2.0.0" }

我不知道如何使用Chris Paton的解决方案

答案 4 :(得分:0)

将Visual Studio 2017更新到最新的15.4.1版本为我解决了这个问题。

相关问题