.net core VSTS生成:无法还原包-无法解析“.NETStandard,Version=v2.0”的“NETStandard.Library(>=1.6.1)”

.net core VSTS生成:无法还原包-无法解析“.NETStandard,Version=v2.0”的“NETStandard.Library(>=1.6.1)”,.net-core,azure-devops,azure-pipelines,.net-core-2.0,.net-standard-2.0,.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并将我的库升级到netstandard2.0之后,使用Hosted2017生成代理进行VSTS生成 在当地效果很好 我已编辑生成定义以使用.net核心生成任务v2。*预览: 以下是生成日志: Current agent version: '2.120.2' Download all required

我要走了

无法解析“.NETStandard,Version=v2.0”的“NETStandard.Library>=1.6.1”

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

在当地效果很好

我已编辑生成定义以使用.net核心生成任务v2。*预览:

以下是生成日志:

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
******************************************************************************
下面是源代码:

您应该选择feed我在这里选择feed以供feed使用选项。如果将此VSTS/TFS提要中的使用包保留为空,则将从下载包

否则,如果要将my NuGet.config中的源用作要使用的源,则应指定NuGet.config文件的路径。

2017年9月18日更新

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

原始答案

我也经历过这个问题,通过做三件事解决了它:

使用.NET核心SDK!-不是运行时!版本2.0.0:

使用最新的NuGet feed 4.3.0:

恢复您的软件包:

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

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


我希望这能帮助你和其他遇到这个问题的人。如果你有任何问题,请告诉我

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

在csproj中:

改变

<TargetFramework>netcoreapp1.1.0</TargetFramework>


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

在使用dotnet new angular生成项目后,我收到了一个类似的错误,该项目创建了一个依赖netcoreapp2.0的项目。对项目属性的检查显示,未正确识别版本2.0,并且未显示在已安装的框架列表中


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

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

看起来代理上使用了1.0.4 SDK,托管代理可能还没有用2.0.0 SDK更新,但您可以看到在恢复中使用了v2.0.5任务就是这个任务。我看到C:\Program Files\dotnet\sdk\1.0.4我还添加了安装v2.0.0的.NET核心工具安装程序任务,仍然是相同的outputHmm,这看起来像是当我检查源时,我在这里选择了源,而不是在我的NuGet.config中预选的源,并确保同时检查了NuGet.org中的使用包,它可以工作。有人能验证一下吗?实际上,它可以与.NET核心任务2.*预览和1.*一起使用,但我必须添加.NET核心工具安装程序构建任务。是否我的构建代理尚未更新?在还原任务的2.*中,我必须取消选择Nuget.config中的提要,因为我没有提要。也许它可以默认为nuget.org包源代码?谢谢。然而,仅仅这一步是不够的。如果没有.NET Core Tool Installer build任务,它在我的情况下不起作用。好的,既然你已经解决了问题,你可以为你的步骤添加一个答案并标记它。或者,如果你解决了Chris在另一个答案中提到的步骤,你可以标记他的答案。这也会让其他有类似问题的人受益。在我的例子中,当我禁用use Nuget 4.3 resp 4.*时,它也会起作用。在我的例子中,可能是因为该工具已经被缓存了。太棒了。我向你致敬,朋友!我仍然收到错误:d:\a\u tool\dncs\2.0.0\x64\dotnet.exe失败,返回代码:1个包无法访问restore@PankajRawat你确定你使用的是最新版本的nuget吗?如果你没有软件包目录,你有没有告诉它从nuget.org获取你的软件包?@ChrisPaton是的,我没有软件包目录。你确定吗?因为此问题与VST而不是Visual Studio有关?升级到.netCore 2.0后,我在Visual Studio生成中遇到了相同的错误。我有Visual studio 15.2版。将visual studio更新到最新版本15.4.1后,问题已得到解决
<TargetFramework>netcoreapp2.0</TargetFramework>
"sdk": { "version": "1.1.0" }
"sdk": { "version": "2.0.0" }