LoginSignup
1
0

More than 1 year has passed since last update.

Linux(Gentoo)でC#

Posted at

Linux(Gentoo)にC#をインストールしてみた。

インストール

emerge --ask --autounmask=y --autounmask-write virtual/dotnet-sdk
etc-update
emerge virtual/dotnet-sdk

「virtual/dotnet-sdk」をインストールしますが、私のマシンの場合はマスクが掛かっていたので解除しています。

バージョン確認

インストールできたか確認も兼ねてバージョンを確認します。

dotnet --version

私の場合は「5.0.301」と表示されました。

apo@gentoo ~/Documents/project/make/cs/hello $ dotnet --version
5.0.301

プロジェクトの作成

dotnet new console

上記を実行すると下記のようなファイルやフォルダが作成されています。

apo@gentoo ~/Documents/project/make/cs/test $ ls -la
total 8
drwxr-xr-x 3 apo apo  54 Sep 25 08:40 .
drwxr-xr-x 4 apo apo  31 Sep 25 08:40 ..
drwxr-xr-x 2 apo apo 165 Sep 25 08:40 obj
-rw-r--r-- 1 apo apo 186 Sep 25 08:40 Program.cs
-rw-r--r-- 1 apo apo 171 Sep 25 08:40 test.csproj

「Program.cs」ファイルの中身は下記のとおり

using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

ビルド

dotnet build

実行

dotnet run

下記のとおりの結果となります。

apo@gentoo ~/Documents/project/make/cs/test $ dotnet run
Hello World!

以上

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0