当前位置: 移动技术网 > IT编程>开发语言>.net > coreRT 和 Native 编译netcore AOT程序

coreRT 和 Native 编译netcore AOT程序

2018年08月26日  | 移动技术网IT编程  | 我要评论

美国10次了,晓月兔,隔山取火

aot是预编译成本地程序,避免jit动态编译存在的性能问题。

netcore一个吸引人的项目,就是基于corert 运行时的本地编译技术,下面我来替大家尝试一下它究竟表现如何。

<project sdk="microsoft.net.sdk">

  <propertygroup>
    <restoresources>https://dotnet.myget.org/f/dotnet-core/api/v3/index.json</restoresources>
    <outputtype>exe</outputtype>
    <targetframework>netcoreapp2.0</targetframework>
  </propertygroup>

  <itemgroup>
    <packagereference include="microsoft.dotnet.ilcompiler" version="1.0.0-alpha-*" />

  </itemgroup>

</project>


首先要在项目文件添加相关的包源,也就是:

<restoresources>https://dotnet.myget.org/f/dotnet-core/api/v3/index.json</restoresources>

然后引用包:

<packagereference include="microsoft.dotnet.ilcompiler" version="1.0.0-alpha-*" />

因为还没有正式版,所以要把版本号写清楚,否则会提示找不到该包。

用命令发布:

dotnet publish -r win-x64 -c release

会提示错误:error : platform linker not found. to fix this problem, download and install visual studio 2017 from . make sure to install the desktop development for c++ workload.

微软就是喜欢这里一块那里一块,就不能好好提供一站式服务吗?没办法,下载安装c++ 环境。这个要4gb,不知道有什么越过的方法。

经测试,在win7 sp1 x64 虚拟机环境下可以正常执行。

hello world程序不到4m大小。感觉还可以。

其他

只支持64位生成,而且不能交叉编译,也就是不能在windows编译linux程序。在win7下面测试成功,winxp提示不是有效32位(不知道在xp 64版会怎样)。不知道能否支持win vista。

ps。当这个native包更新后,他会替换默认的编译器,不知道怎么换回来。。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网