LoginSignup
3
2

More than 1 year has passed since last update.

新規マシンのUbuntuに.net 5をインストールしアプリを実行する

Last updated at Posted at 2022-04-26

Ubuntuに.Net5をインストールする

最新は.net6ですが5を指定してインストールします。

Ubuntuに.netをインストールするやり方

  • Snapでインストール
  • マイクロソフトから提供されたスクリプトでインストール
  • 手動でランタイムやSDKをインストール

スクリプトが一番簡単でした。

スクリプトでインストールする

このページからdotnet-install.shをダウンロードします。

バージョンを指定します。

$ bash ./dotnet-install.sh -c 5.0
環境変数DOTNET_ROOTを設定する

Vimをインストール

sudo apt-get install vim
環境変数ファイルを編集する

~/.profileよりも.bashrcのほうが必ず読み込まれためここに追加します。

vim ~/.bashrc

最後に追加する

export DOTNET_ROOT=$HOME/.dotnet 

反映させる

source ~/.bashrc

DOTNET_ROOTが設定されたか確認する

env

変数が設定されていると以下のように出ます

DOTNET_ROOT=/home/user/.dotnet

DOTNET_ROOTにパスが通ってなかったりすると以下のようなエラーが出ます。

A fatal error occurred. The required library libhostfxr.so could not be found.
If this is a self-contained application, that library should exist in [].
If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].

参考情報引用

環境変数の読み込み順番

  1. /etc/profile

  2. ~/.bash_profile 
    上のファイルがなければ
    2-1. ~/.bash_login
    2-2. ~/.profile

  3. ~/.bashrc

  4. /etc/bashrc

  5. bash実行

  6. /etc/profile
    このファイルはログイン時に読み込む全てのユーザ共通の設定が書いています。

    ~/.bash_profile 
    その後ユーザの[home]ディレクトリにある「.bash_profile 」を
    読み込みます。
    上のファイルがなければ下の順に読み込めます。
    2-1. ~/.bash_login
    2-2. ~/.profile
    ログインの時一回だけ読み込みます。

    ~/.bashrc
    このファイルはbashが読みこまれる度に更新されます。
    設定を変更する時は[bash]とコマンドを打って設定ファイルへの更新が反映されます。

    /etc/bashrc
    このファイルはシステム全体の関数とエイリアスに関する設定が記録されています。ここでデフォルトのプロンプトを決める「PS1」の設定などをしています。

GateIoライブラリを使ってみるに続く

3
2
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
3
2