.NET 6.0 は 古いOSだと windows 7 sp1 から対応していてmacでもLinuxでも動いて良いかも、と思いました。
インストール
curl -O -L -s "https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb"
sudo apt update && sudo apt install -y apt-transport-https
sudo apt install -y dotnet-sdk-6.0
dotnet --version
プロジェクトの作成
mkdir console && cd console
# dotnet new プロジェクト名
dotnet new console
サンプル
dotnet run
- hello world が表示されることを確認。9秒くらいかかる。
build
dotnet build
- 8秒くらいかかった。
# ビルドされたものを実行
bin/Debug/net6.0/console
- 瞬時に実行された。
ランタイム同梱
64 MB 程になる。
dotnet build --sc -r linux-x64
dotnet build --sc -r win-x86
dotnet build --sc -r win-x64
dotnet build --sc -r osx-x64
dotnet build --sc -r win
-r は以下指定
ランタイム同梱しない場合
- 150 kb 程度で済む。
dotnet build -r win-x86 --sc=false