跨平台发布

简单新建一个项目。

mkdir dotnethello

cd dotnethello

dotnet new

dotnet new之后 修改project.json 如下:

{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform", //去掉
"version": "1.0.0-rc2-*"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
},
"runtimes":{//加入runtime
"win7-x64": { },
"win7-x86": { },
"osx.10.10-x64": { },
"osx.10.11-x64": { },
"Ubuntu.14.04-x64":{ }
}
}

添加NuGet.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="AspNetCI" value="https://www.myget.org/F/aspnetcirelease/api/v3/index.json" />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

dotnet restore

还原以后就可以编译发布了。

Windows:

这里默认输入 dotnet publish 会发布 win7-x64 。

我们定位到 win7-x64\publish 文件夹,可以直接执行 dotnethello.exe ,无需安装.netcore sdk 。

Ubuntu:

我们要发布到linux ubuntu 直接指定 runtime 。

dotnet publish -r ubuntu.14.04-x64

把发布文件夹(ubuntu.14.04-x64/publish)拷贝到ubuntu上。

直接就可以执行,不需要安装.netcore sdk,只需.netcore依赖的几个包:

https://github.com/dotnet/cli/blob/rel/1.0.0/Documentation/cli-prerequisites.md

Ubuntu distributions require the following libraries installed:

  • libunwind8
  • libunwind8-dev
  • gettext
  • libicu-dev
  • liblttng-ust-dev
  • libcurl4-openssl-dev
  • libssl-dev
  • uuid-dev
  • unzip

设置文件夹下的执行文件dotnethello 设置好权限以后直接 ./dotnethello

Mac OS:

同理mac os 一样,指定osx runtime。

dotnet publish -r osx.10.10-x64

将 osx.10.10-x64/publish 拷贝到mac os 。

OS X 需要安装libssl

OS X requires the following libraries and versions installed:

  • libssl 1.1

执行dotnethello

这样我们无需安装.NET Core SDK 就可以运行.NET Core 应用程序。实现了.NET Core 跨平台。

原文 http://www.linuxidc.com/Linux/2016-07/133202.htm  作者:linezero

最新文章

  1. EC笔记:第三部分:14、在资源管理类中小心Copying行为
  2. Bete冲刺第七阶段
  3. 统计学 nested_design 嵌套设计
  4. C标准库&lt;ctype.h&gt;实现
  5. Codeforces Round #Pi (Div. 2) C. Geometric Progression map
  6. cocos2d-x android 字体的设置
  7. JS 生成GUID
  8. Linux 块设备驱动 (二)
  9. 精通CSS+DIV基础总结(二)
  10. 【Oracle】number类型保留小数位
  11. Java 八大类型、String和 StringBuffer
  12. 11G内存设置一例
  13. Spring Boot 的Maven多模块开发web项目使用外部容器进行部署
  14. Vue获取事件源
  15. python3字典中items()和python2.x中iteritems()有什么不同?
  16. 转载:指针delete后要设置为NULL
  17. shell脚本学习-执行
  18. 使用 WLST 和节点管理器来管理服务器
  19. spark踩坑——dataframe写入hbase连接异常
  20. css移动端:acitve效果的实现

热门文章

  1. 关于Asset Library核心功能的一些计划
  2. mysql 设置初始密码
  3. 【如皋OJ】1127:正整数N转换成一个二进制数
  4. oracle死锁的处理办法
  5. .Net Core跨平台应用研究-CustomSerialPort(增强型跨平台串口类库)
  6. 同一主机设置多个密钥与不同github账号关联,或同一主机同一密钥分别关联github和gitlab
  7. Elasticsearch-6.7.0系列(一)9200端口 .tar.gz版本centos7环境--下载安装运行
  8. 生产者消费者synchronized wait notify
  9. quartz.properties完整版
  10. 样式初始化(copy)