VSTS构建:软件包还原失败-无法为'.NETStandard,Version = v2.0'解析'NETStandard.Library(> = 1.6.1)' [英] VSTS build: Packages failed to restore - Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'

查看:214
本文介绍了VSTS构建:软件包还原失败-无法为'.NETStandard,Version = v2.0'解析'NETStandard.Library(> = 1.6.1)'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在


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


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



在本地可以正常工作。



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





这是构建日志:

 当前代理版本:'2.120.2'
下载所有必需的任务。
下载任务:DotNetCoreCLI

开始:获取资源
同步存储库:Liero / vyvojari-sk(GitHub)
...省略详细信息
HEAD is现在位于e448a25 ...升级到.NET Core 2.0
整理:获取源

开始:还原
=============== ================================================== =============
任务:.NET Core
描述:构建,测试,打包或发布dotnet应用程序,或运行自定义dotnet命令。对于包命令,支持NuGet.org以及经过身份验证的提要,例如包管理和 MyGet。
版本:2.0.5
作者:Microsoft Corporation
帮助:[更多信息](https://go.microsoft.com/fwlink/?linkid=832194)
= ================================================== ===========================
SYSTEMVSSCONNECTION存在true
下载:https://dist.nuget.org/ win-x86-commandline / v4.0.0 / nuget.exe
缓存工具:NuGet 4.0.0 x64
使用版本:4.0.0
在缓存中找到工具:NuGet 4.0.0 x64
将NuGet.config保存到一个临时配置文件。
找不到密钥的位置字符串:NGCommon_NoSourcesFoundInConfig
NGCommon_NoSourcesFoundInConfig d:\a\1\Nuget\tempNuGet_734.config
C:\Program Files\ dotnet\dotnet.exe恢复d:\a\1\srcsCommandCommandCommand\CommandStack.csproj --configfile d:\a\1\Nuget\tempNuGet_734.config- -verbosity详细的
还原d:\a\1\s\src\CommandStack\CommandStack.csproj ......
C:\Program Files\dotnet\的软件包sdk\1.0.4\NuGet.targets(97,5):错误:无法为'.NETStandard,Version = v2.0'解析'NETStandard.Library(> = 1.6.1)'。 [d:\a\1\srcsCommandStack\CommandStack.csproj]
生成MSBuild文件d:\a\1\srcsCommandCommand\ obj\CommandStack.csproj.nuget.g.props。
生成MSBuild文件d:\a\1\srcsCommandCommand\obj\CommandStack.csproj.nuget.g.targets。
将锁定文件写入磁盘。路径:d:\a\1\s\src\CommandStack\obj\project.assets.json
d:\a\1\s还原在115.64毫秒内失败\src\CommandStack\CommandStack.csproj。

d:\a\1\srcsCommandCommand\CommandStack.csproj中的错误
无法解析'NETStandard.Library(> = 1.6.1 )代表 .NETStandard,Version = v2.0。

使用的NuGet配置文件:
d:\a\1\Nuget\tempNuGet_734.config
错误:C:\Program Files\dotnet\dotnet .exe失败,返回码:1
程序包无法还原
****************************** ****************************************************
整理:还原
********************************************* ******************************************

,这是源代码:


  • 还原软件包:


  • 更新
    这里值得一提的是,您应该指定从哪里获取NuGet软件包的位置。根据屏幕截图(请参阅小复选框),大多数应用程序可能仅使用NuGet.org提要,但您可能已在NuGet.config文件中指定了自定义提要。在这种情况下,勾选 Feed in my NuGet.config,然后指定该文件的路径。



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



    我希望这对您和其他遇到此问题的人有帮助。如果您有任何疑问,请告诉我。 :)


    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:

    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

    解决方案

    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:

    2. Use the latest NuGet feed (4.3.0):

    3. Restore your packages:

    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:

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

    这篇关于VSTS构建:软件包还原失败-无法为'.NETStandard,Version = v2.0'解析'NETStandard.Library(> = 1.6.1)'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆