docker - Gitlab CI docker环境下无法恢复mono项目的nuget包

标签 docker nuget gitlab-ci

该项目是在 Mono 下开发的,依赖于一些 nuget 包。我使用 Gitlab CI 来运行构建。构建环境是docker ubuntu。所有其他 apt-get 安装工作正常,但无论我如何修改参数和 NuGet.config,nuget 都不会恢复包。我在 v2 和 v3 之间切换,并尝试了我在互联网上可以找到的所有内容:

http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

http://docs.myget.org/docs/how-to/package-not-found-during-package-restore

但仍然出现以下错误:

gitlab-ci-multi-runner 1.1.4 (9e2fd1a)
Using Docker executor with image ruby:2.1 ...
Pulling docker image ruby:2.1 ...
...
$ apt-get update -qq && apt-get install -y -qq
$ apt-get install -y -qq mono-complete
...
$ wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
...
$ mono nuget.exe restore monotest.sln -Source http://nuget.org/api/v2
MSBuild auto-detection: using msbuild version '4.0' from '/usr/lib/mono/4.5'.
Restoring NuGet package MongoDB.Bson.2.2.3.
Restoring NuGet package MongoDB.Driver.2.2.3.
Restoring NuGet package MongoDB.Driver.Core.2.2.3.
Restoring NuGet package Newtonsoft.Json.8.0.3.
WARNING: Unable to find version '2.2.3' of package 'MongoDB.Bson'.
  /root/.local/share/NuGet/Cache: Package 'MongoDB.Bson.2.2.3' is not found on source '/root/.local/share/NuGet/Cache'.
  http://nuget.org/api/v2: Unable to load the service index for source http://nuget.org/api/v2.
  This method must be implemented in derived classes

WARNING: Unable to find version '8.0.3' of package 'Newtonsoft.Json'.
  /root/.local/share/NuGet/Cache: Package 'Newtonsoft.Json.8.0.3' is not found on source '/root/.local/share/NuGet/Cache'.
  http://nuget.org/api/v2: Unable to load the service index for source http://nuget.org/api/v2.
  This method must be implemented in derived classes

WARNING: Unable to find version '2.2.3' of package 'MongoDB.Driver'.
  /root/.local/share/NuGet/Cache: Package 'MongoDB.Driver.2.2.3' is not found on source '/root/.local/share/NuGet/Cache'.
  http://nuget.org/api/v2: Unable to load the service index for source http://nuget.org/api/v2.
  This method must be implemented in derived classes

WARNING: Unable to find version '2.2.3' of package 'MongoDB.Driver.Core'.
  /root/.local/share/NuGet/Cache: Package 'MongoDB.Driver.Core.2.2.3' is not found on source '/root/.local/share/NuGet/Cache'.
  http://nuget.org/api/v2: Unable to load the service index for source http://nuget.org/api/v2.
  This method must be implemented in derived classes


Errors in packages.config projects
    Unable to find version '2.2.3' of package 'MongoDB.Bson'.
      /root/.local/share/NuGet/Cache: Package 'MongoDB.Bson.2.2.3' is not found on source '/root/.local/share/NuGet/Cache'.
      http://nuget.org/api/v2: Unable to load the service index for source http://nuget.org/api/v2.
      This method must be implemented in derived classes
    Unable to find version '8.0.3' of package 'Newtonsoft.Json'.
      /root/.local/share/NuGet/Cache: Package 'Newtonsoft.Json.8.0.3' is not found on source '/root/.local/share/NuGet/Cache'.
      http://nuget.org/api/v2: Unable to load the service index for source http://nuget.org/api/v2.
      This method must be implemented in derived classes
    Unable to find version '2.2.3' of package 'MongoDB.Driver'.
      /root/.local/share/NuGet/Cache: Package 'MongoDB.Driver.2.2.3' is not found on source '/root/.local/share/NuGet/Cache'.
      http://nuget.org/api/v2: Unable to load the service index for source http://nuget.org/api/v2.
      This method must be implemented in derived classes
    Unable to find version '2.2.3' of package 'MongoDB.Driver.Core'.
      /root/.local/share/NuGet/Cache: Package 'MongoDB.Driver.Core.2.2.3' is not found on source '/root/.local/share/NuGet/Cache'.
      http://nuget.org/api/v2: Unable to load the service index for source http://nuget.org/api/v2.
      This method must be implemented in derived classes

NuGet Config files used:
    /builds/renkun-ken/monotest/.nuget/NuGet.config
    /root/.config/NuGet/NuGet.Config

Feeds used:
    /root/.local/share/NuGet/Cache
    http://nuget.org/api/v2

ERROR: Build failed: exit code 1

引用资料:

https://docs.nuget.org/consume/package-restore

https://docs.nuget.org/consume/command-line-reference

在我的本地机器上,我可以使用完全相同的命令从在线源成功恢复所有包。

最佳答案

根据您使用的 Ubuntu 版本,将 ca-certificates-mono 添加到您的环境中可能会有所帮助:

apt-get install -y --allow-unauthenticated ca-certificates-mono

我将 Docker 与 Stretch 和 this thread 结合使用修复了我与你的相同的问题。

关于docker - Gitlab CI docker环境下无法恢复mono项目的nuget包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37312664/

相关文章:

apache - 502 代理错误(docker + traefik + apache)

docker - Docker 上的 Headless Chromium 失败

c# - VS2013 构建不包括项目依赖项的 Nuget 依赖项的二进制文件

gitlab - 如何将值传递给来自文件的gitlab管道变量

gitlab-ci - 在 GUI 上查看时,如何折叠我的 GitLab CI 作业日志的一部分?

docker - 如何在gitlab ci中合并Dockerfile?

linux - 在 Docker 中的卷之间移动文件很慢

php - 如何通过phpMyAdmin连接到mysql docker容器?

nuget - 如何在nuget和项目引用之间有效切换?

asp.net-core - 使用 .NET 标准库 .csproj 时,如何将 NuGet contentFiles CopyToOutput 设置为 true?