【问题标题】:Nuget fails to restore NetStandard.Libary for netstandard1.2 in Build Agent build for VS Team ServicesNuget 无法在 VS Team Services 的 Build Agent 构建中恢复 NetStandard.Library for net standard 1.2
【发布时间】:2016-09-06 14:51:29
【问题描述】:

我有一个带有以下 project.json 的 netstandard1.2 项目

{
  "supports": {},
  "dependencies": {
    "NETStandard.Library": "1.6.0"
  },
  "frameworks": {
    "netstandard1.2": {}
  }
}

此项目包含在一个解决方案中,该解决方案包含面向 4.5.1 的 .NET Framework 项目(其他几个项目引用此 netstandard1.2 项目,但项目本身不引用任何其他项目)。

在 Visual Studio 2015 Update 3 (NuGet 3.5.0) 中一切都恢复和构建正常,但是当构建服务器(Team Services 的本地构建代理,更新到最新的 2.105.1)运行 vNext 步骤以恢复包时解决方案,我得到错误:

无法为“.NETStandard,Version=v1.2”解析“NETStandard.Library (>= 1.6.0)”。

我做过的事情:

  • 构建服务器上的 Visual Studio 2015 已更新到更新 3
  • .Net Core 预览工具安装在构建服务器上
  • 最新的 NuGet 在构建服务器上
  • vNext 构建中的 NuGet 还原步骤指向最新的 NuGet(而不是 Team Services 构建代理附带的 v3.3.0)
  • 使用安装在构建器服务器上的 Visual Studio 2015 成功构建解决方案(VS 已安装 NuGet 3.5.0 扩展)

我有什么遗漏或可以尝试的吗?

来自 NuGet 的更详细输出:

2016-09-06T14:28:43.0788201Z ##[debug]   C:\BuildAgent\_work\17\s\.nuget\NuGet.Config
2016-09-06T14:28:43.0798020Z [command]D:\nuget.exe restore -NonInteractive C:\BuildAgent\_work\17\s\MySolution.sln -ConfigFile C:\BuildAgent\_work\17\s\.nuget\NuGet.Config
2016-09-06T14:28:43.4458345Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
2016-09-06T14:28:43.8138208Z All packages listed in packages.config are already installed.
2016-09-06T14:28:43.8618591Z Restoring packages for C:\BuildAgent\_work\17\s\MyProject\project.json...
2016-09-06T14:28:43.9588089Z Unable to resolve 'NETStandard.Library (>= 1.6.0)' for '.NETStandard,Version=v1.2'.
2016-09-06T14:28:43.9848100Z Committing restore...
2016-09-06T14:28:43.9898096Z Writing lock file to disk. Path: C:\BuildAgent\_work\17\s\MyProject\project.lock.json
2016-09-06T14:28:44.0038195Z C:\BuildAgent\_work\17\s\MyProject\MyProject.csproj
2016-09-06T14:28:44.0048116Z Restore failed in 163ms.
2016-09-06T14:28:44.0108191Z Errors in C:\BuildAgent\_work\17\s\MyProject\MyProject.csproj
2016-09-06T14:28:44.0108191Z     Unable to resolve 'NETStandard.Library (>= 1.6.0)' for '.NETStandard,Version=v1.2'.
2016-09-06T14:28:44.0118109Z NuGet Config files used:
2016-09-06T14:28:44.0118109Z     C:\BuildAgent\_work\17\s\.nuget\NuGet.Config
2016-09-06T14:28:44.0268561Z ##[debug]rc:1
2016-09-06T14:28:44.0278115Z ##[debug]success:false
2016-09-06T14:28:44.0288120Z ##[error]Error: D:\nuget.exe failed with return code: 1
2016-09-06T14:28:44.0298129Z ##[error]Packages failed to install

更新:这是我的 Nuget.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
</configuration>

【问题讨论】:

  • 您是否尝试过在没有 vNext 步骤的情况下恢复包?请直接使用 Visual Studio on builder agent for VSO 恢复,这可以帮助我们确认此问题是由 Visual Studio 环境引起的还是 vNext 步骤引起的。
  • @Wendy 是的,在构建器服务器上安装的 VS 中构建(安装了 VSO 构建代理)工作正常(安装的 VS 具有 NuGet 3.5.0 扩展)
  • 我无法重现该问题,能否分享您在还原任务中指定的 NuGet.Config 文件中的设置?
  • @Eddie-MSFT 现在更新了 NuGet.config。
  • 里面没有包源?

标签: visual-studio-2015 nuget azure-devops azure-pipelines .net-standard


【解决方案1】:

清除构建代理中的 nuget 缓存后,我设法重现了您的问题。解决这个问题的方法是在 nuget restore 任务中不指定 nuget.config 文件,或者在 nuget.config 文件中添加 nuget 包源。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
 <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

【讨论】:

  • 谢谢。这似乎是有道理的,因为我在删除我的 project.json 项目后遇到了 NuGet 3.5.0 解析包的问题。我认为这是一个需要记录的错误?
  • @OffHeGoes 是的,我同意你的看法。
  • 知道在哪里记录了 NuGet 错误 - 我在 GitHub 上找不到问题页面...?
  • 非常感谢。将首先使用 3.4.4 和 3.5.0 自己验证这一点。
  • 已确认并记录。显然这是设计使然,NuGet 3.5 不再有默认包源,因此您必须指定它。 github.com/NuGet/Home/issues/3426
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-09-27
  • 2017-07-08
  • 1970-01-01
  • 1970-01-01
  • 2018-05-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多