设为首页 收藏本站
查看: 2091|回复: 0

[经验分享] .netcore2.0 发布CentOS7

[复制链接]

尚未签到

发表于 2017-11-22 08:01:49 | 显示全部楼层 |阅读模式
  1.一般在windows pc上使用vscode 开发好.netcore 程序如果需要发布到其他平台需要注意一些事情
  首先需要明白2个概念:FDD(Framework-dependent deployment)和 SCD (Self-contained deployment)




2.# FDD


Framework-dependent deployment. As the name implies, framework-dependent deployment (FDD) relies on the presence of a shared system-wide version of .NET Core on the target system. Because .NET Core is already present, your app is also portable between installations of .NET Core. Your app contains only its own code and any third-party dependencies that are outside of the .NET Core libraries. FDDs contain .dll files that can be launched by using the dotnet utility from the command line. For example, dotnet app.dll runs an application named app.

3.#





SCD



Self-contained deployment. Unlike FDD, a self-contained deployment (SCD) doesn't rely on the presence of shared components on the target system. All components, including both the .NET Core libraries and the .NET Core runtime, are included with the application and are isolated from other .NET Core applications. SCDs include an executable (such as app.exe on Windows platforms for an application named app), which is a renamed version of the platform-specific .NET Core host, and a .dll file (such as app.dll), which is the actual application.
参考:https://docs.microsoft.com/en-us/dotnet/core/deploying/deploy-with-cli

4.# RIDs



Windows RIDs

Windows 7 / Windows Server 2008 R2

win7-x64

win7-x86

Windows 8 / Windows Server 2012

win8-x64

win8-x86

win8-arm

Windows 8.1 / Windows Server 2012 R2

win81-x64

win81-x86

win81-arm

Windows 10 / Windows Server 2016

win10-x64

win10-x86

win10-arm

win10-arm64

Linux RIDs

Red Hat Enterprise Linux

rhel.7-x64

Ubuntu

ubuntu.14.04-x64

ubuntu.14.10-x64

ubuntu.15.04-x64

ubuntu.15.10-x64

ubuntu.16.04-x64

ubuntu.16.10-x64

CentOS

centos.7-x64

Debian

debian.8-x64

Fedora

fedora.23-x64

fedora.24-x64

OpenSUSE

opensuse.13.2-x64

opensuse.42.1-x64

Oracle Linux

ol.7-x64

ol.7.0-x64

ol.7.1-x64

ol.7.2-x64

Currently supported Ubuntu derivatives

linuxmint.17-x64

linuxmint.17.1-x64

linuxmint.17.2-x64

linuxmint.17.3-x64

linuxmint.18-x64

1

OS X RIDs

osx.10.10-x64

osx.10.11-x64

osx.10.12-x64
参考:https://docs.microsoft.com/zh-cn/dotnet/core/rid-catalog

5.# 修改 .csproj 项目文件



<RuntimeIdentifiers>win7-x64;centos.7-x64</RuntimeIdentifiers>
  完整如下图:
DSC0000.png

  6.# 直接执行 build 如果依赖项目较多可能会等很久
DSC0001.png

  先执行 dotnet restore 命令
DSC0002.png
  这样会下载安装一些依赖项目等完成后
DSC0003.png

  再执行 build 命令
DSC0004.png

  测试下在 windows 下是 ok 的
DSC0005.png

  最后执行publish 指令:



dotnet publish -c Release -r centos.7-x64
  最后会生成Release版本:
DSC0006.png

  最后生成文件非常多:
DSC0007.png

  下一步使用FTP工具上传到 CentOS publish 目录:
DSC0008.png

  最后一步使用 putty 命令执行就可以了



dotnet xxx.dll
DSC0009.png

  --------------------------------------------------------------------------------------------------------------
  注意事项 以上是基于 FDD模式 (感觉4G技术 娃哈哈哈哈)
  要提前手工安装 .netcore 2.0 SDK
  参考命令如下:



# 解压安装文件
$ tar -xzf ~/dotnet/dotnet-dev-centos-x64.1.0.0-preview1-002702.tar.gz
# 软连接
ln -s /home/jake/leak/dotnet/dotnet /usr/local/bin
# 删除软连接
rm -rf /usr/local/bin/dotnet
# 查看版本
dotnet --version

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-409401-1-1.html 上篇帖子: 19.cloudera 下篇帖子: 远程连接Linux虚拟机上的mysql失败的解决方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表