一、简介

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

二、方法:

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

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

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

      dotnet publish -r linux-arm

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

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

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

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

     

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

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

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

  5、运行程序:

    ./pitest

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

 

  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

 

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

 

相关文章:

  • 2022-12-23
  • 2021-09-01
  • 2021-04-20
  • 2022-01-08
  • 2021-06-03
  • 2021-12-24
  • 2022-01-01
猜你喜欢
  • 2022-02-07
  • 2022-12-23
  • 2021-04-14
  • 2021-07-06
  • 2021-06-03
  • 2022-12-23
相关资源
相似解决方案