centos7安装netcore 5, build 找不到私有nuget服务

一、Centos 7上安装net5的方法如下:

sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sudo yum install dotnet-sdk-5.0

上面的安装好,下面2个都不需要安装了。 

sudo yum install aspnetcore-runtime-5.0
sudo yum install dotnet-runtime-5.0

官方介绍:

https://docs.microsoft.com/zh-cn/dotnet/core/install/linux-centos

如果已安装 SDK 或运行时,请使用 dotnet --list-sdks 和 dotnet --list-runtimes 命令查看安装了哪些版本。

二、搭建私有Nuget服务,则服务器上的配置

1、 dotnet build 找不到本地文件或私有Nuget服务器的解决方法,需要服务器上安装dotnet的sdk

如果用命令行编译或者发布到服务器上编译,需要修改一下Nuget.Config文件,这个文件在Windows下大概目录是C:\Users\你的登陆名\AppData\Roaming\NuGet\NuGet.Config,在Linux下大概目录是/root/.nuget/NuGet/NuGet.Config,把这个文件打开添加上你自己的nuget服务器地址就可以了。

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

2、Dockerfile看不到本地文件或私有Nuget服务器

如下代码  dotnet restore 添加2个包源,2个-s,一个是官方的,一个是内网的。

RUN dotnet restore "FONE.Gateway/FONE.Gateway.csproj" -s http://10.10.1.66:1000/v3/index.json -s https://api.nuget.org/v3/index.json
原文地址:https://www.cnblogs.com/puzi0315/p/15534427.html