.Net Native 跨平台尝试

微软平台的开源愈演愈烈,在前两天的Connect()上,不仅发布了最新的.Net Core RC1,而且进一步开源了.Net Native跨平台实现。

.Net Native 运行时:

https://github.com/dotnet/corert

.NET 命令行工具链:

https://github.com/dotnet/cli

 

.Net Native提供了普通模式和cpp模式:

普通模式 类似现有的uwp .Net Native,将IL直接编译成机器码然后与运行库链接。

cpp模式 将IL编译成c++源码,然后使用c++编译器编译,类似于unity3d的IL2CPP,这种方式将具有很好的跨平台前景。

 

以下是Linux Ubuntu 14.04尝试过程(Windows下失败):

安装方法mono

https://github.com/dotnet/corert/blob/master/Documentation/prerequisites-for-building.md

安装必要工具

apt-get update
apt-get -y install curl libicu-dev libunwind8 gettext libssl-dev libcurl4-openssl-dev zlib1g
apt-get -y install autoconf automake build-essential libtool

 

在cli项目中提供了deb安装包与tar.gz两种格式,我下载deb安装并修复依赖

mkdir dotnetcli
cd dotnetcli
wget https://dotnetcli.blob.core.windows.net/dotnet/dev/Installers/Latest/dotnet-linux-x64.latest.deb
dpkg -i dotnet-linux-x64.latest.deb
apt-get -y -f install

然后设置环境变量(如需重新启动可用,可以写入/etc/profile文件)

export DOTNET_HOME=/usr/share/dotnet

输入 dotnet 可以看到以下输出表示安装成功

.NET Command Line Interface
Usage: dotnet [common-options] [command] [arguments]

Arguments:
  [command]     The command to execute
  [arguments]   Arguments to pass to the command

Common Options (passed before the command):
  -v|--verbose  Enable verbose output

Common Commands:
  compile       Compiles a .NET project
  publish       Publishes a .NET project for deployment
  run           Compiles and immediately executes a .NET project

使用git 下载示例代码

cd /root
git clone https://github.com/dotnet/core.git

先恢复nuget包

cd /root/core/samples/helloworld
dotnet restore

使用.Net Native 普通模式编译

dotnet compile --native

使用.Net Native cpp模式编译

dotnet compile --native --cpp

没有错误则代表成功,可以运行测试

cd /root/core/samples/helloworld/bin/Debug/dnxcore50/native
ls
./helloworld

可以看到成功输出

Hello World!

注意:当前.Net Native仅可以运行samples下的helloworld和dotnetbot,不过相信很快就可以全面使用,因为开发已接近尾声,现在问题在工具之前的配合

转载于:https://www.cnblogs.com/loqi/p/4980272.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值