树莓派3中运行Netcore2.0程序

一、简介

  Netcore2.0发部后,可以运行在Arm平台上。因此,我们可以尝试在装了Debain的树莓派中运行。

二、方法:

  1、在自己的电脑上使用VS写一个NetCore2.0的控制台程序,我假设我就写个Helloworld。

    

  2、在项目目录下使用cmd命令执行:

      dotnet publish -r linux-arm

    说明:-r表示运行平台,可以是win-arm、linux-arm、win-x86、win-x64等等。

    

  3、打开项目所在目录下的binDebug etcoreapp2.0linux-arm目录,会看到一个叫publish的文件夹。

    把这个文件夹复制到树莓派上。

     

      

  4、添加执行权限:chmod 777 ./pitest

    说明:其中pitest是项目输出的主程序的名称。

  5、运行程序:

    ./pitest

    

  6、如果运行失败,是因为Netcore需要依赖一些第三方库。需要事先在树莓派上安装下列环境:

    参考官网:https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md

    依赖项:https://github.com/dotnet/core/blob/master/Documentation/prereqs.md

    我在刚装的Debain运行之前,安装的依赖项是:libunwind8gettext,其它的包也没装

    sudo apt-get install curl libunwind8 gettext

    

原文地址:https://www.cnblogs.com/songxingzhu/p/7399991.html