1、新建.netcore项目
2、编辑.csproj文件
<Project Sdk="Microsoft.NET.Sdk"> ?<PropertyGroup> ???<OutputType>Exe</OutputType> ???<TargetFramework>netcoreapp2.0</TargetFramework> ???<RuntimeIdentifiers>centos.7-x64</RuntimeIdentifiers> ?</PropertyGroup></Project>
在PropertyGroup下加入RuntimeIdentifiers节点,并设置为centos.7-x64
3、在项目上点发布按钮,按照流程发布
打开发布后的文件,上传至centos系统
4、centos上安装对应的环境
yum install libunwind -yyum install icu -y
5、为程序添加执行权限
chmod u+x ConsoleApp1
6、执行程序
./ConsoleApp1
结果正确
.net core编译并发布至centos平台
原文地址:http://www.cnblogs.com/jiecaoge/p/7637108.html