【问题标题】:Team Build Nuget restore failure with .NET Core 2.0 + .Net Standard 2.0Team Build Nuget 使用 .NET Core 2.0 + .Net Standard 2.0 还原失败
【发布时间】:2018-09-27 16:28:34
【问题描述】:

我有一个 VS2017 解决方案,其中包含一个 .NET Core 2.0 控制台项目,该项目引用一个 .NET Standard 2.0 类库,以及许多其他 NuGet 包。该解决方案在我的开发机器上构建良好。

当我尝试使用 NuGet 4.0.0 或 4.1.0 在 TFS 构建服务器上运行 NuGet 还原时,我收到以下错误:

    Package (mypackagename) 1.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package (mypackagename) 1.0.0 supports:
  - net35 (.NETFramework,Version=v3.5)
  - netstandard2.0 (.NETStandard,Version=v2.0)

此错误消息类似于Nuget restore fails for ASP.NET Core 2.0 project on build server 中描述的错误消息,因此我尝试了那里建议的解决方案,即使用 NuGet 4.3.0 或更高版本。我已经尝试了从 4.3.0 到 4.6.2 的所有发布版本,这次我从 NuGet 还原中收到以下错误:

2018-04-17T15:45:15.2611952Z Value cannot be null.
2018-04-17T15:45:15.2611952Z Parameter name: key
2018-04-17T15:45:15.2611952Z System.ArgumentNullException: Value cannot be null.
2018-04-17T15:45:15.2611952Z Parameter name: key
2018-04-17T15:45:15.2611952Z    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
2018-04-17T15:45:15.2611952Z    at NuGet.Commands.RestoreCommandProvidersCache.GetOrCreate(String globalPackagesPath, IReadOnlyList`1 fallbackPackagesPaths, IReadOnlyList`1 sources, SourceCacheContext cacheContext, ILogger log)
2018-04-17T15:45:15.2611952Z    at NuGet.Commands.DependencyGraphSpecRequestProvider.Create(String projectNameToRestore, ExternalProjectReference project, HashSet`1 projectReferenceClosure, RestoreArgs restoreArgs, DependencyGraphSpec projectDgSpec)
2018-04-17T15:45:15.2611952Z    at NuGet.Commands.DependencyGraphSpecRequestProvider.GetRequestsFromItems(RestoreArgs restoreContext, DependencyGraphSpec dgFile)
2018-04-17T15:45:15.2611952Z    at NuGet.Commands.DependencyGraphSpecRequestProvider.CreateRequests(RestoreArgs restoreContext)
2018-04-17T15:45:15.2611952Z    at NuGet.Commands.RestoreRunner.<CreatePreLoadedRequests>d__11.MoveNext()
2018-04-17T15:45:15.2611952Z --- End of stack trace from previous location where exception was thrown ---

关于如何让这个工作的任何建议?

【问题讨论】:

    标签: visual-studio-2017 nuget tfsbuild nuget-package-restore


    【解决方案1】:

    我通过在 Team Build 的“获取源”任务中设置“Clean = True”来解决此问题。

    完成此操作后,我可以使用最新版本的 NuGet (4.6.2),它不再抛出上面的 ArgumentNullException。

    我怀疑 NuGet 中存在错误,它会被先前构建留下的文件混淆。

    【讨论】:

    猜你喜欢
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多