Raspberry Pi で .Net Core を使う

SDK をダウンロードします。

dotnet-sdk-3.0.101-linux-arm.tar.gz

解凍します。

mkdir dotnet
cp dotnet-sdk-3.0.101-linux-arm.tar.gz dotnet
cd dotnet
tar xvfz dotnet-sdk-3.0.101-linux-arm.tar.gz

PATH の設定を .bashrc に加えます。

.bashrc
#
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet

ログインし直してバージョンの確認

$ dotnet --version
3.0.101

プロジェクトの作成

mkdir Test01
cd Test01
dotnet new console

次のようなファイルが出来ます。

$ ls
Program.cs  Test01.csproj  obj

Program.cs の改行記号を取って、 p01.cs というプログラムを作ります。

tr -d "\r" < Program.cs > p01.cs

Program.cs を削除し、p01.cs を次のように改造します。

p01.cs
using System;

namespace Test01
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine("This is a Test!");
        }
    }
}

コンパイルと実行

$ dotnet run
Hello World!
This is a Test!

次の環境で確認しました。

$ uname -a
Linux pansy 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account