Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSTS build: Packages failed to restore - Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'

I'm getting

Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'.

in VSTS build using Hosted2017 build agent after I upgraded my aspnetcore app to netcoreapp2.0 and my libraries to use netstandard2.0.

Works fine locally.

I've edited my build definition to use .net core build task v2.* preview:

build definition details

here is the build log:

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

and here is the source code: https://github.com/Liero/vyvojari-sk/tree/e448a25fb8c481704e9102aaaeb8b84b9aee7b02

like image 530
Liero Avatar asked Aug 16 '17 15:08

Liero


3 Answers

Update 18/09/2017

Step 2 is no longer needed. I've left it in the solution though as it may still help some people. Thanks, @Liero for point this out.


Original Answer

I've just experienced this problem too and solved it by doing three things:

  1. Use the .NET Core SDK(! - not runtime!) version 2.0.0: enter image description here

  2. Use the latest NuGet feed (4.3.0): enter image description here

  3. Restore your packages: enter image description here

Update It's worth mentioning here that you should specify where you get your NuGet packages from. Most applications will probably just use the NuGet.org feed, as per the screenshot (see small checkbox), but you may have your custom feeds specified in a NuGet.config file. In that case, tick 'Feeds in my NuGet.config' and then specify the path to that file.

To illustrate the order, this is my working queue: enter image description here

I hope this helps you and anyone else who has come up against this problem. If you have any questions, let me know. :)

like image 79
Chris Paton Avatar answered Nov 18 '22 03:11

Chris Paton


You should select Feed(s) I select here for Feeds to use option. If you leave Use packages from this VSTS/TFS feed empty, packages will be downloaded from https://dist.nuget.org/.

enter image description here

Else, if you want to use Feeds in my NuGet.config as Feeds to use, you should specify the path for your NuGet.config file.

like image 45
Marina Liu Avatar answered Nov 18 '22 05:11

Marina Liu


I have received a similar error after generating a project using dotnet new angular which created a project relying on netcoreapp2.0. Inspection of project properties revealed that version 2.0 was not properly recognized (did not appear in the installed framework list).

Solution was to update Visual Studio 2017, as the minimum version required to support netcoreapp2.0 projects seems to be 15.3.1.

like image 1
Alexei - check Codidact Avatar answered Nov 18 '22 04:11

Alexei - check Codidact