Raspberry pi 3b+ 安装dotnet5 VSCode Remote-SSH 远程开发

前言

VSCode 安装Remote-SSH 配置好树莓派 

VSCode 自带SSH控制台

终端输入命令

下载&安装 net5

下载
wget https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.205/dotnet-sdk-5.0.205-linux-arm.tar.gz 安装 mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-5.0.205-linux-arm.tar.gz -C $HOME/dotnet

安装完毕后 创建demo

mkdir demo&cd demo
dotnet new console -o demodev

  

ps bash: dotnet: command not found
如果报错根据微软docs文档,导入环境变量

export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet

  

 先国际惯例 hello world!~

iot

添加iot库 控制引脚 这库使用BCM编码17号 以下所有序号都是以BCM位置

dotnet add package System.Device.Gpio

using System;
using System.Device.Gpio;
using System.Threading;

namespace demodev
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World! runtime pi");
            var pin = 17;
            var lightTimeInMilliseconds = 500;
            var dimTimeInMilliseconds = 200;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine($"Let's blink an LED!");

            
            using (GpioController controller = new GpioController())
            {
                controller.OpenPin(pin, PinMode.Output);
                Console.WriteLine($"GPIO pin enabled for use: {pin}");
                Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs eventArgs) =>
                {
                    controller.Dispose();
                };
                while (true)
                {
                    Console.WriteLine($"Light for {lightTimeInMilliseconds}ms");
                    controller.Write(pin, PinValue.High);
                    Thread.Sleep(lightTimeInMilliseconds);
                    Console.WriteLine($"Dim for {dimTimeInMilliseconds}ms");
                    controller.Write(pin, PinValue.Low);
                    Thread.Sleep(dimTimeInMilliseconds);
                }
            }
        }
    }
}
dotnet run  

ps:如果编译不过同 得先 dotnet restore

 

 

 

总结

win10 敲代码 liunx直接 运行..这.....这也太爽了吧???   期待VS也上这个功能 太需要了..

原文地址:https://www.cnblogs.com/leoxjy/p/15054193.html