Ubuntu 12.10にASP.NET Core 1.0をインストールしようとして失敗した話
Linux (Ubuntu)環境でASP.NETアプリを動かしてみる。
基本的には下記のサイトの説明にしたがって環境構築していく。
Installing ASP.NET 5 On Linux — ASP.NET documentation
Linux向けのASP.NETはASP.NET 5 RC 。Release Candidate。
あと、最近名称が変わってASP.NET Core 1.0というのが今後は使われていくらしい。
NETの実行環境には3種類あって、目的、環境に合わせて選択することができる。
- .NET Framework
- .NET Core
- Mono
.NET Frameworkは昔からある本家の.NET。フルパッケージ。ただし、Windows環境でのみ動く。
.NET Coreは、.NET Frameworkのサブセット。ポータブルなランタイムCoreCLRとライブラリCoreFXからなる。Windowsだけでなく、Linux、Mac OS環境でも動く。MS主体のオープンソースプロジェクトとして開発されており、ソースの参照が可能なことはもちろん、開発への参加も可能。
Monoは.NET FrameworkをWindows環境以外でも動くようにポーティングしたもの。オープンソースプロジェクト。MSによる実装ではない。
では、インストールしてみる。
まず、DNVM(.NET Version Manager)なるものをインストールする。これは.NETの実行環境(DNX = .NET Execution Environment)を管理するためのツール。DNXは.NET CoreかMono。それぞれに異なるバージョンが存在する。それら複数のDNXを管理して、どのDNXを使うかを設定する。
必要となるツールをapt-getで入れた後に、DNVMインストール用のシェルスクリプトをダウンロードしてきて実行する。
sudo apt-get install unzip curl curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
実行するとDNVMの実体であるdnvm.shがとあるサイトから自動でダンロードされて、~/.dnx/dnvm/dnvm.shに保存される。
さらに~/bashrcに下記のコマンドが追加されて、ログイン時にdnvm.shが読み込まれるようになる。
[ -s "/home/xxxxx/.dnx/dnvm/dnvm.sh" ] && . "/home/xxxxx/.dnx/dnvm/dnvm.sh" # Load dmvm
DNVMのインストール後はdnvmコマンドが使えるようになっている。
$ dnvm ___ _ ___ ____ ___ / _ \/ |/ / | / / |/ / / // / /| |/ / /|_/ / /____/_/|_/ |___/_/ /_/ .NET Version Manager - Version 1.0.0-rc2-15546 By Microsoft Open Technologies, Inc. DNVM can be used to download versions of the .NET Execution Environment and manage which version you are using. You can control the URL of the stable and unstable channel by setting the DNX_FEED and DNX_UNSTABLE_FEED variables. Current feed settings: Default Stable: https://www.nuget.org/api/v2 Default Unstable: https://www.myget.org/F/aspnetvnext/api/v2 Current Stable Override:Current Unstable Override: Use dnvm [help|-h|-help|--help] to display help text.
DNVMがインストールできたので、DNVMを使って、.NET Coreをインストールしてみる。
インストールために必要なパッケージがあるのでまずは入れる。
sudo apt-get install libunwind8 gettext libssl-dev libcurl4-openssl-dev zlib1g libicu-dev uuid-dev
.NET Coreのインストール。
$ dnvm upgrade -r coreclr Determining latest version Latest version is 1.0.0-rc1-update2 Downloading dnx-coreclr-linux-x64.1.0.0-rc1-update2 from https://www.nuget.org/api/v2 Download: https://www.nuget.org/api/v2/package/dnx-coreclr-linux-x64/1.0.0-rc1-update2 ######################################################################## 100.0% Installing to /home/xxxxx/.dnx/runtimes/dnx-coreclr-linux-x64.1.0.0-rc1-update2 Adding /home/xxxxx/.dnx/runtimes/dnx-coreclr-linux-x64.1.0.0-rc1-update2/bin to process PATH Setting alias 'default' to 'dnx-coreclr-linux-x64.1.0.0-rc1-update2'
~/.dnx/runtimesの下に.NET Coreのファイルがダウンロードされる。
あと、PATH環境変数にそこへのパスが追加されるのと、dnvmのdefault設定に.NET Core rc1 update2が設定される。
$ cat ~/.dnx/alias/default.alias dnx-coreclr-linux-x64.1.0.0-rc1-update2
(.NET ASPのページではDNVMを使わない.NET Coreのインストール方法も書かれているが、そこでダウンロードできるのはdnx-coreclr-linux-x64.1.0.0-rc1-update1.tar.gz。DNVMを使った場合はupdate2がダウンロードされてきたので、DNVMを使った方がいいかも。)
ここまでで.NET Coreのインストールは完了のはず。
だが、dnxコマンドやdnuコマンドを実行しても、何の出力もされない。。。
どうもうまく動いていない様子。
ほぼ同じ手順でMax OS環境にもセッティングしてみたが、こちらはうまくいった。
つかっているUbuntuのバージョンが古いことがまずいのだろうか?
Linux quetzal 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Mac OS Xの出力
$ dnx --help Microsoft .NET Execution environment CoreClr-x64-1.0.0-rc1-16609 Usage: dnx [options] Options: --project|-pPath to the project.json file or the application folder. Defaults to the current folder if not provided. --appbase Application base directory path --lib Paths used for library look-up --debug Waits for the debugger to attach before beginning execution. --bootstrapper-debug Waits for the debugger to attach before bootstrapping runtime. -?|-h|--help Show help information --version Show version information --watch Watch file changes --packages Directory containing packages --configuration The configuration to run under --port The port to the compilation server
Ubuntu 12.10の出力
$ dnx --help
何のエラーも出ない。。。