いろいろ備忘録日記

主に .NET とか Go とか Flutter とか Python絡みのメモを公開しています。

.NETインストールスクリプトを使ってSDKをインストール

概要

以下、自分用のメモです。忘れないうちにメモメモ。。。

Chromebook上のLinuxに dotnet 入れようと思って、Microsoftのサイト見てたら以下のようなページを発見。

dotnet.microsoft.com

こんなの提供されてたんですねー知らなかったです。私のLinux環境はARM64になるので手動で入れないといけないなーって思ってました。

試してみる

てことで、この .NET インストールスクリプト を使ってインストールしてみます。

まずは、このシェルスクリプトを落としましょう。

$ wget https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh
--2023-06-19 01:17:22--  https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh
dotnet.microsoft.com (dotnet.microsoft.com) をDNSに問いあわせています... 13.107.213.47, 13.107.246.47, 2620:1ec:bdf::47, ...
dotnet.microsoft.com (dotnet.microsoft.com)|13.107.213.47|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
dotnet.microsoft.com からのクッキーがドメインを次のように設定しようとしました。dotnetwebsite.azurewebsites.net
dotnet.microsoft.com からのクッキーがドメインを次のように設定しようとしました。dotnetwebsite.azurewebsites.net
長さ: 58994 (58K) [application/x-sh]
`dotnet-install.sh' に保存中

dotnet-install.sh                    100%[====================================================================>]  57.61K  --.-KB/s 時間 0.09s    

2023-06-19 01:17:23 (667 KB/s) - `dotnet-install.sh' へ保存完了 [58994/58994]

そのままシェルスクリプトをオプション無しで実行すると、LTS版 (6.0) がインストールされます。

私の場合は、STS (7.0) の方を使いたいので、チャネルを STS (7.0) にして実行します。

$ bash dotnet-install.sh --channel STS
dotnet-install: Attempting to download using aka.ms link https://dotnetcli.azureedge.net/dotnet/Sdk/7.0.304/dotnet-sdk-7.0.304-linux-arm64.tar.gz
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/7.0.304/dotnet-sdk-7.0.304-linux-arm64.tar.gz
dotnet-install: Installed version is 7.0.304
dotnet-install: Adding to current process PATH: `~/.dotnet`. Note: This change will be visible only when sourcing script.
dotnet-install: Note that the script does not resolve dependencies during installation.
dotnet-install: To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the "Dependencies" section.
dotnet-install: Installation finished successfully.

無事入ったみないなので、あとは確認

$ ~/.dotnet/dotnet --version
7.0.304

オッケイ。楽ですねー。削除したい場合は ~/.dotnet ディレクトリをまるごと削除すればオッケイです。

参考情報

dotnet-install スクリプト - .NET CLI | Microsoft Learn


過去の記事については、以下のページからご参照下さい。

サンプルコードは、以下の場所で公開しています。