Dot-Net-Core

VSTS 建構:包無法還原 - 無法解析 ‘.NETStandard,Version=v2.0’ 的 ‘NETStandard.Library (>= 1.6.1)’

  • August 16, 2017

我越來越

無法為“.NETStandard,Version=v2.0”解析“NETStandard.Library (>= 1.6.1)”。

在我將我的 aspnetcore 應用程序升級到netcoreapp2.0我的庫以使用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
******************************************************************************

這是原始碼:https ://github.com/Liero/vyvojari-sk/tree/e448a25fb8c481704e9102aaaeb8b84b9aee7b02

2017 年 9 月 18 日更新

不再需要第 2 步。我把它留在了解決方案中,因為它仍然可以幫助一些人。謝謝@Liero 指出這一點。


原始答案

我也剛剛遇到過這個問題,並通過做三件事來解決它:

  1. 使用 .NET Core SDK(!- 不是執行時!) 2.0.0 版: 在此處輸入圖像描述
  2. 使用最新的 NuGet 源 (4.3.0): 在此處輸入圖像描述
  3. 恢復你的包: 在此處輸入圖像描述

更新 這裡值得一提的是,您應該指定從哪裡獲取 NuGet 包。大多數應用程序可能只使用 NuGet.org 提要,如螢幕截圖所示(請參閱小複選框),但您可能會在 NuGet.config 文件中指定自定義提要。在這種情況下,勾選“我的 NuGet.config 中的提要”,然後指定該文件的路徑。

為了說明順序,這是我的工作隊列: 在此處輸入圖像描述

我希望這對您和其他遇到此問題的人有所幫助。如果您有任何問題,請告訴我。:)

引用自:https://stackoverflow.com/questions/45717283