読者です 読者をやめる 読者になる 読者になる

into the void

ソフトウェアに関する雑多な調査日記

Ubuntu 14.04でASP.NET Core 1.0を動かしてみる

Ubuntu 12.10でうまくいかなかったので、14.04環境に変えて仕切り直し。
前回と
intothevoid.hatenablog.com
全く同じ手順で、さくっとインストール完了。dnxが動作するようになった。

$ uname -a
Linux ik1-303-11997 3.13.0-86-generic #130-Ubuntu SMP Mon Apr 18 18:27:15 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="14.04.4 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.4 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
$ dnx --help
Microsoft .NET Execution environment CoreClr-x64-1.0.0-rc1-16609

Usage: dnx [options]

Options:
  --project|-p               Path 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

YOEMANのインストール

YOEMANのインストールは下記のページが詳しかった。
Node.jsのアプリとしての実装のようで、Node.jsが必要。
Yeoman: Getting it to Work on Ubuntu - Truthy Falsey

Node.jsをいれて、そのあとでNode.jsのパッケージ管理ツールであるNPMも入れる。
node.jsのサイトからnode-v4.4.4-linux-x64.tar.xzをダウンロードしてきて展開して使った。
https://nodejs.org/en/

$ mkdir ~/nodejs
$ cd ~/nodejs
$ xz node-v4.4.4-linux-x64.tar.xz
$ tar -xvf node-v4.4.4-linux-x64.tar

nodeコマンドとnpmコマンドがパス指定しなくても実行できるように.bashrcにexportを追加しておく。

export PATH=$PATH:/home/xxxxx/nodejs/node-v4.4.4-linux-x64/bin

npmをつかって必要なパッケージをインストールする。
最初にnpm自身をアプデートしておく。(しておかないとyoのインストール時にWARNが出た)

$ npm install -g nam
$ npm yo grunt-cli bower
$ npm install -g generator-webapp
$ npm install -g generator-aspnet

まずはConsoleアプリケーションを作ってみて、.NET Coreが動作することを確認する。

shizuku@ik1-303-11997:~$ mkdir dntest
shizuku@ik1-303-11997:~$ cd dntest/
shizuku@ik1-303-11997:~/dntest$ yo aspnet

     _-----_
    |       |    .--------------------------.
    |--(o)--|    |      Welcome to the      |
   `---------´   |   marvellous ASP.NET 5   |
    ( _´U`_ )    |        generator!        |
    /___A___\    '--------------------------'
     |  ~  |     
   __'.___.'__   
 ´   `  |° ´ Y ` 

? What type of application do you want to create? Console Application
? What's the name of your ASP.NET application? ConsoleApp1
   create ConsoleApp1/.gitignore
   create ConsoleApp1/Program.cs
   create ConsoleApp1/project.json


Your project is now created, you can use the following commands to get going
    cd "ConsoleApp1"
    dnu restore
    dnu build (optional, build will also happen when it's run)
    dnx run

生成されるテンプレートは下記のような中身。

ConsoleApp1$ find .
.
./project.lock.json
./Program.cs
./.gitignore
./project.json

project.jsonに設定情報が。

$ cat project.json 
{
  "version": "1.0.0-*",
  "description": "ConsoleApp1 Console Application",
  "authors": [ "" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "compilationOptions": {
    "emitEntryPoint": true
  },

  "tooling": {
    "defaultNamespace": "ConsoleApp1"
  },

  "dependencies": {
  },

  "commands": {
    "ConsoleApp1": "ConsoleApp1"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.Console": "4.0.0-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  }
}


dnu restoreを実行するとこのプロジェクトの実行に必要なライブラリがダウンロードされる。
何が必要かはおそらくproject.jsonのdependenciesから決定される。

dun buildでビルド。で、失敗。
なかなかうまくいかないな。

.NET Coreのアプリケーションは、異なる複数の環境で実行されることを前提に作ることができるらしい。
.NET Frameworkとか、.NET Coreとか。
project.jsonのframeworkのところで、対応する環境を定義するらしい。dnx451というのが.NET Framework。dnxcore50というのが.NET Core。
さっきdun buildでエラーが出ていたのは、dnx451のモジュールのようだったので、ひとまずproject.jsonからdnx451を削除してみた。(今回はLinuxの.NET Core環境でアプリを動作させることが目的なので、.NET Frameworkのサポートは不要)
https://docs.asp.net/en/latest/conceptual-overview/dotnetcore.html

すると、ビルドは通り、dnx runでの実行も成功。やっと動いた。まだコンソールアプリだけど。
たしかにMonoなしで、.NET Core 1.0 (CoreCLR + CoreFX)でC#アプリが動くようになっている。

$ dnx run
Hello World

ビルドした後のディレクトリの中はこんな感じ。

ConsoleApp1$ find .
.
./project.lock.json
./bin
./bin/Debug
./bin/Debug/dnxcore50
./bin/Debug/dnxcore50/ConsoleApp1.xml
./bin/Debug/dnxcore50/ConsoleApp1.dll
./project.json.org
./Program.cs
./.gitignore
./project.json

ちゃんとMONO/.Net用のバイナリができている。なかなか面白い。

file ./bin/Debug/dnxcore50/ConsoleApp1.dll 
./bin/Debug/dnxcore50/ConsoleApp1.dll: PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows

ASP.NET Webアプリの作成

YOEMANでWebアプリのテンプレートをつくる。

$ yo aspnet

     _-----_
    |       |    .--------------------------.
    |--(o)--|    |      Welcome to the      |
   `---------´   |   marvellous ASP.NET 5   |
    ( _´U`_ )    |        generator!        |
    /___A___\    '--------------------------'
     |  ~  |     
   __'.___.'__   
 ´   `  |° ´ Y ` 

? What type of application do you want to create? Web Application
? What's the name of your ASP.NET application? WebApp1
   create WebApp1/gulpfile.js
   create WebApp1/Dockerfile
   create WebApp1/.bowerrc
   create WebApp1/.gitignore
   create WebApp1/appsettings.json
   create WebApp1/bower.json
   create WebApp1/package.json
   create WebApp1/project.json
   create WebApp1/README.md
   create WebApp1/Startup.cs
   create WebApp1/Controllers/AccountController.cs
   create WebApp1/Controllers/HomeController.cs
   create WebApp1/Controllers/ManageController.cs
   create WebApp1/Migrations/00000000000000_CreateIdentitySchema.Designer.cs
   create WebApp1/Migrations/00000000000000_CreateIdentitySchema.cs
   create WebApp1/Migrations/ApplicationDbContextModelSnapshot.cs
   create WebApp1/Models/ApplicationDbContext.cs
   create WebApp1/Models/ApplicationUser.cs
   create WebApp1/Services/IEmailSender.cs
   create WebApp1/Services/ISmsSender.cs
   create WebApp1/Services/MessageServices.cs
   create WebApp1/ViewModels/Account/ExternalLoginConfirmationViewModel.cs
   create WebApp1/ViewModels/Account/ForgotPasswordViewModel.cs
   create WebApp1/ViewModels/Account/LoginViewModel.cs
   create WebApp1/ViewModels/Account/RegisterViewModel.cs
   create WebApp1/ViewModels/Account/ResetPasswordViewModel.cs
   create WebApp1/ViewModels/Account/SendCodeViewModel.cs
   create WebApp1/ViewModels/Account/VerifyCodeViewModel.cs
   create WebApp1/ViewModels/Manage/AddPhoneNumberViewModel.cs
   create WebApp1/ViewModels/Manage/ChangePasswordViewModel.cs
   create WebApp1/ViewModels/Manage/ConfigureTwoFactorViewModel.cs
   create WebApp1/ViewModels/Manage/FactorViewModel.cs
   create WebApp1/ViewModels/Manage/IndexViewModel.cs
   create WebApp1/ViewModels/Manage/ManageLoginsViewModel.cs
   create WebApp1/ViewModels/Manage/RemoveLoginViewModel.cs
   create WebApp1/ViewModels/Manage/SetPasswordViewModel.cs
   create WebApp1/ViewModels/Manage/VerifyPhoneNumberViewModel.cs
   create WebApp1/Views/_ViewImports.cshtml
   create WebApp1/Views/_ViewStart.cshtml
   create WebApp1/Views/Account/ConfirmEmail.cshtml
   create WebApp1/Views/Account/ExternalLoginConfirmation.cshtml
   create WebApp1/Views/Account/ExternalLoginFailure.cshtml
   create WebApp1/Views/Account/ForgotPassword.cshtml
   create WebApp1/Views/Account/ForgotPasswordConfirmation.cshtml
   create WebApp1/Views/Account/Lockout.cshtml
   create WebApp1/Views/Account/Login.cshtml
   create WebApp1/Views/Account/Register.cshtml
   create WebApp1/Views/Account/ResetPassword.cshtml
   create WebApp1/Views/Account/ResetPasswordConfirmation.cshtml
   create WebApp1/Views/Account/SendCode.cshtml
   create WebApp1/Views/Account/VerifyCode.cshtml
   create WebApp1/Views/Home/About.cshtml
   create WebApp1/Views/Home/Contact.cshtml
   create WebApp1/Views/Home/Index.cshtml
   create WebApp1/Views/Manage/AddPhoneNumber.cshtml
   create WebApp1/Views/Manage/ChangePassword.cshtml
   create WebApp1/Views/Manage/Index.cshtml
   create WebApp1/Views/Manage/ManageLogins.cshtml
   create WebApp1/Views/Manage/SetPassword.cshtml
   create WebApp1/Views/Manage/VerifyPhoneNumber.cshtml
   create WebApp1/Views/Shared/_Layout.cshtml
   create WebApp1/Views/Shared/_LoginPartial.cshtml
   create WebApp1/Views/Shared/_ValidationScriptsPartial.cshtml
   create WebApp1/Views/Shared/Error.cshtml
   create WebApp1/wwwroot/css/site.css
   create WebApp1/wwwroot/css/site.min.css
   create WebApp1/wwwroot/favicon.ico
   create WebApp1/wwwroot/images/ASP-NET-Banners-01.png
   create WebApp1/wwwroot/images/ASP-NET-Banners-02.png
   create WebApp1/wwwroot/images/Banner-01-Azure.png
   create WebApp1/wwwroot/images/Banner-02-VS.png
   create WebApp1/wwwroot/js/site.js
   create WebApp1/wwwroot/js/site.min.js
   create WebApp1/wwwroot/web.config


Your project is now created, you can use the following commands to get going
    cd "WebApp1"
    dnu restore
    dnu build (optional, build will also happen when it's run)
    dnx web

dun restoreするとASP.NETの実行に必要なパッケージがnugetからたくさんダウンロードされる。

Installing Microsoft.Extensions.Configuration.UserSecrets.1.0.0-rc1-final
Installing Microsoft.Extensions.Logging.Console.1.0.0-rc1-final
Installing Microsoft.Extensions.PlatformAbstractions.1.0.0-rc1-final
Installing Microsoft.Extensions.Configuration.Abstractions.1.0.0-rc1-final
Installing Microsoft.Extensions.Primitives.1.0.0-rc1-final
Installing Microsoft.Extensions.Logging.Abstractions.1.0.0-rc1-final
Installing Microsoft.Extensions.Logging.Debug.1.0.0-rc1-final
Installing Microsoft.Extensions.Logging.1.0.0-rc1-final
Installing Microsoft.Extensions.DependencyInjection.Abstractions.1.0.0-rc1-final
Installing Microsoft.Extensions.Configuration.FileProviderExtensions.1.0.0-rc1-final
Installing Microsoft.Extensions.Configuration.FileExtensions.1.0.0-rc1-final
Installing Microsoft.AspNet.FileProviders.Physical.1.0.0-rc1-final
Installing Microsoft.AspNet.FileProviders.Abstractions.1.0.0-rc1-final
Installing Microsoft.AspNet.IISPlatformHandler.1.0.0-rc1-final
Installing Microsoft.AspNet.Http.Extensions.1.0.0-rc1-final
Installing Microsoft.Extensions.WebEncoders.Core.1.0.0-rc1-final
Installing Microsoft.Net.Http.Headers.1.0.0-rc1-final
Installing Microsoft.AspNet.Http.Abstractions.1.0.0-rc1-final
Installing Microsoft.AspNet.Http.Features.1.0.0-rc1-final
Installing Microsoft.AspNet.Http.1.0.0-rc1-final
Installing Microsoft.AspNet.WebUtilities.1.0.0-rc1-final
Installing Microsoft.AspNet.StaticFiles.1.0.0-rc1-final
Installing Microsoft.AspNet.Hosting.Abstractions.1.0.0-rc1-final
Installing Microsoft.Extensions.WebEncoders.1.0.0-rc1-final
Installing Microsoft.Extensions.OptionsModel.1.0.0-rc1-final
Installing Microsoft.Extensions.Configuration.Binder.1.0.0-rc1-final
Installing Microsoft.Extensions.Configuration.1.0.0-rc1-final
Installing Microsoft.AspNet.Server.Kestrel.1.0.0-rc1-final
Installing System.Numerics.Vectors.4.1.1-beta-23516
Installing Microsoft.AspNet.Hosting.1.0.0-rc1-final
Installing Microsoft.Extensions.DependencyInjection.1.0.0-rc1-final
Installing Microsoft.Dnx.Compilation.Abstractions.1.0.0-rc1-final
Installing Microsoft.Extensions.Configuration.CommandLine.1.0.0-rc1-final
Installing Microsoft.AspNet.Hosting.Server.Abstractions.1.0.0-rc1-final
Installing Microsoft.Extensions.Configuration.EnvironmentVariables.1.0.0-rc1-final
Installing System.Diagnostics.DiagnosticSource.4.0.0-beta-23516
Installing System.Diagnostics.Tracing.4.0.0
Installing System.Threading.4.0.0
Installing Microsoft.AspNet.Tooling.Razor.1.0.0-rc1-final
Installing Microsoft.AspNet.Razor.Runtime.4.0.0-rc1-final
Installing Microsoft.AspNet.Html.Abstractions.1.0.0-rc1-final
Installing Microsoft.AspNet.Razor.4.0.0-rc1-final
Installing Newtonsoft.Json.6.0.6
Installing Microsoft.Extensions.Configuration.Json.1.0.0-rc1-final
Installing Microsoft.AspNet.Authentication.Cookies.1.0.0-rc1-final
Installing Microsoft.AspNet.Authentication.1.0.0-rc1-final
Installing Microsoft.AspNet.DataProtection.1.0.0-rc1-final
Installing Microsoft.AspNet.Cryptography.Internal.1.0.0-rc1-final
Installing Microsoft.AspNet.DataProtection.Abstractions.1.0.0-rc1-final
Installing Microsoft.AspNet.Diagnostics.Entity.7.0.0-rc1-final
Installing Microsoft.AspNet.Diagnostics.1.0.0-rc1-final
Installing Microsoft.AspNet.Diagnostics.Abstractions.1.0.0-rc1-final
Installing EntityFramework.Relational.7.0.0-rc1-final
Installing EntityFramework.Core.7.0.0-rc1-final
Installing Microsoft.Extensions.Caching.Abstractions.1.0.0-rc1-final
Installing Microsoft.Extensions.Caching.Memory.1.0.0-rc1-final
Installing System.Collections.Immutable.1.1.36
Installing Ix-Async.1.2.5
Installing Remotion.Linq.2.0.1
Installing EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final
Installing Microsoft.AspNet.Identity.EntityFramework.3.0.0-rc1-final
Installing Microsoft.AspNet.Identity.3.0.0-rc1-final
Installing Microsoft.AspNet.Cryptography.KeyDerivation.1.0.0-rc1-final
Installing EntityFramework.Commands.7.0.0-rc1-final
Installing EntityFramework.Relational.Design.7.0.0-rc1-final
Installing EntityFramework.Sqlite.7.0.0-rc1-final
Installing Microsoft.Data.Sqlite.1.0.0-rc1-final
Installing Microsoft.Dnx.Runtime.1.0.0-rc1-final
Installing Microsoft.Dnx.Loader.1.0.0-rc1-final
Installing Microsoft.CodeAnalysis.CSharp.1.1.0-rc1-20151109-01
Installing Microsoft.CodeAnalysis.Common.1.1.0-rc1-20151109-01
Installing System.Collections.Immutable.1.1.37
Installing System.Diagnostics.Debug.4.0.0
Installing System.Collections.4.0.0
Installing System.Linq.4.0.0
Installing System.Runtime.Extensions.4.0.0
Installing Microsoft.CodeAnalysis.Analyzers.1.0.0
Installing System.Reflection.Metadata.1.1.0
Installing System.Runtime.InteropServices.4.0.0
Installing System.Text.Encoding.Extensions.4.0.0
Installing Microsoft.AspNet.Mvc.6.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.Localization.6.0.0-rc1-final
Installing Microsoft.AspNet.Localization.1.0.0-rc1-final
Installing Microsoft.Extensions.Localization.Abstractions.1.0.0-rc1-final
Installing Microsoft.Extensions.Globalization.CultureInfoCache.1.0.0-rc1-final
Installing Microsoft.Extensions.Localization.1.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.Cors.6.0.0-rc1-final
Installing Microsoft.AspNet.Cors.6.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.Core.6.0.0-rc1-final
Installing Microsoft.AspNet.Authorization.1.0.0-rc1-final
Installing Microsoft.Extensions.MemoryPool.1.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.Abstractions.6.0.0-rc1-final
Installing Microsoft.AspNet.Routing.1.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.DataAnnotations.6.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.ApiExplorer.6.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.Formatters.Json.6.0.0-rc1-final
Installing Microsoft.AspNet.JsonPatch.1.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.ViewFeatures.6.0.0-rc1-final
Installing Microsoft.AspNet.Antiforgery.1.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.Razor.6.0.0-rc1-final
Installing Microsoft.AspNet.PageExecutionInstrumentation.Interfaces.1.0.0-rc1-final
Installing Microsoft.AspNet.Razor.Runtime.Precompilation.4.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.Razor.Host.6.0.0-rc1-final
Installing Microsoft.Dnx.Compilation.CSharp.Abstractions.1.0.0-rc1-final
Installing Microsoft.Dnx.Compilation.CSharp.Common.1.0.0-rc1-final
Installing Microsoft.AspNet.Mvc.TagHelpers.6.0.0-rc1-final
Installing Microsoft.Extensions.FileSystemGlobbing.1.0.0-rc1-final
Installing Microsoft.Extensions.CodeGenerators.Mvc.1.0.0-rc1-final
Installing Microsoft.Extensions.CodeGeneration.Templating.1.0.0-rc1-final
Installing Microsoft.Extensions.CodeGeneration.EntityFramework.1.0.0-rc1-final
Installing Microsoft.Extensions.CodeGeneration.Core.1.0.0-rc1-final
Installing Microsoft.Extensions.CodeGeneration.1.0.0-rc1-final
Installing System.Runtime.Serialization.Primitives.4.0.11-beta-23409
Installing System.Resources.ResourceManager.4.0.1-beta-23516
Installing System.Collections.4.0.10
Installing System.AppContext.4.0.0
Installing System.IO.FileSystem.Watcher.4.0.0-beta-23516
Installing System.IO.FileSystem.Primitives.4.0.1-beta-23516
Installing System.IO.FileSystem.4.0.1-beta-23516
Installing System.IO.4.0.11-beta-23516
Installing System.Text.RegularExpressions.4.0.11-beta-23516
Installing System.Runtime.Extensions.4.0.11-beta-23516
Installing System.Collections.Concurrent.4.0.11-beta-23516
Installing System.Diagnostics.Tracing.4.0.20
Installing System.Reflection.Extensions.4.0.1-beta-23516
Installing System.Threading.4.0.10
Installing System.ComponentModel.4.0.1-beta-23516
Installing System.Diagnostics.Debug.4.0.11-beta-23516
Installing System.Diagnostics.Tools.4.0.1-beta-23516
Installing System.Threading.Thread.4.0.0-beta-23516
Installing System.Security.Cryptography.Algorithms.4.0.0-beta-23516
Installing System.Security.Cryptography.Primitives.4.0.0-beta-23516
Installing System.Globalization.4.0.11-beta-23516
Installing System.Reflection.4.1.0-beta-23225
Installing System.Runtime.InteropServices.4.0.21-beta-23516
Installing System.Linq.Expressions.4.0.11-beta-23516
Installing System.Dynamic.Runtime.4.0.11-beta-23516
Installing System.Reflection.Emit.4.0.0
Installing System.Reflection.Emit.ILGeneration.4.0.0
Installing System.Linq.Expressions.4.0.10
Installing System.Threading.Tasks.4.0.11-beta-23516
Installing System.Text.Encoding.4.0.11-beta-23516
Installing System.Security.Claims.4.0.1-beta-23516
Installing System.Security.Principal.4.0.1-beta-23516
Installing System.Linq.Queryable.4.0.1-beta-23516
Installing System.ComponentModel.TypeConverter.4.0.1-beta-23516
Installing System.ComponentModel.Primitives.4.0.0
Installing System.Globalization.Extensions.4.0.1-beta-23516
Installing System.Net.Primitives.4.0.11-beta-23516
Installing System.Reflection.TypeExtensions.4.0.1-beta-23409
Installing System.Net.WebSockets.4.0.0-beta-23516
Installing Microsoft.Win32.Primitives.4.0.0
Installing System.Security.Cryptography.X509Certificates.4.0.0-beta-23516
Installing System.Security.Cryptography.Encoding.4.0.0-beta-23516
Installing System.Text.Encoding.Extensions.4.0.11-beta-23516
Installing System.IO.4.0.10
Installing System.Runtime.Handles.4.0.1-beta-23516
Installing System.Data.Common.4.0.1-beta-23516
Installing System.Collections.NonGeneric.4.0.0
Installing System.ComponentModel.Annotations.4.0.11-beta-23516
Installing System.ObjectModel.4.0.11-beta-23516
Installing System.Diagnostics.Contracts.4.0.1-beta-23516
Installing System.Threading.ThreadPool.4.0.10-beta-23516
Installing System.Threading.Timer.4.0.1-beta-23516
Installing System.Diagnostics.TraceSource.4.0.0-beta-23516
Installing System.Diagnostics.Tracing.4.0.21-beta-23516
Installing System.Diagnostics.StackTrace.4.0.1-beta-23516
Installing System.Security.Principal.Windows.4.0.0-beta-23516
Installing System.Security.Principal.4.0.0
Installing System.Security.Claims.4.0.0
Installing System.Net.Http.4.0.1-beta-23516
Installing System.Net.Primitives.4.0.0
Installing Microsoft.Win32.Registry.4.0.0-beta-23516
Installing System.Xml.XDocument.4.0.11-beta-23516
Installing System.Diagnostics.Tools.4.0.0
Installing System.Xml.ReaderWriter.4.0.10
Installing System.IO.FileSystem.4.0.0
Installing System.Threading.Overlapped.4.0.0
Installing System.Text.RegularExpressions.4.0.10
Installing System.Text.Encoding.CodePages.4.0.1-beta-23516
Installing System.Data.SqlClient.4.0.0-beta-23516
Installing System.Xml.ReaderWriter.4.0.0
Installing System.Data.Common.4.0.0
Installing System.Text.RegularExpressions.4.0.0
Installing System.ComponentModel.4.0.0
Installing System.Reflection.4.1.0-beta-23516
Installing System.AppContext.4.0.1-beta-23516
Installing System.Runtime.Loader.4.0.0-beta-23516
Installing System.Resources.ReaderWriter.4.0.0-beta-23516
Installing System.Xml.ReaderWriter.4.0.11-beta-23516
Installing System.Threading.Tasks.Parallel.4.0.1-beta-23516
Installing System.Collections.Concurrent.4.0.10
Installing System.Diagnostics.Process.4.0.0-beta-23409
Installing runtime.unix.System.Diagnostics.Debug.4.0.11-beta-23516
Installing runtime.linux.System.Runtime.Extensions.4.0.11-beta-23516
Installing runtime.linux.System.Security.Cryptography.Algorithms.4.0.0-beta-23516
Installing runtime.linux.System.IO.FileSystem.4.0.1-beta-23516
Installing runtime.linux.System.IO.FileSystem.Watcher.4.0.0-beta-23516
Installing runtime.any.System.Linq.Expressions.4.0.11-beta-23516
Installing System.Reflection.Emit.Lightweight.4.0.0
Installing runtime.unix.System.Globalization.Extensions.4.0.1-beta-23516
Installing runtime.unix.System.Net.Primitives.4.0.11-beta-23516
Installing runtime.unix.System.Security.Cryptography.Encoding.4.0.0-beta-23516
Installing System.Collections.Concurrent.4.0.0
Installing runtime.unix.System.Security.Cryptography.X509Certificates.4.0.0-beta-23516
Installing System.Security.Cryptography.OpenSsl.4.0.0-beta-23516
Installing System.Runtime.Numerics.4.0.0
Installing System.Globalization.Calendars.4.0.0
Installing runtime.linux.System.Net.Http.4.0.1-beta-23516
Installing runtime.unix.System.Diagnostics.TraceSource.4.0.0-beta-23516
Installing runtime.linux.System.Diagnostics.Process.4.1.0-beta-23409
Installing System.Threading.ThreadPool.4.0.10-beta-23409
Installing runtime.unix.System.Text.Encoding.CodePages.4.0.1-beta-23516
Installing runtime.unix.System.Data.SqlClient.4.0.0-beta-23516
Installing System.Net.Security.4.0.0-beta-23516
Installing System.Net.NameResolution.4.0.0-beta-23516
Installing System.Threading.Timer.4.0.0
Installing System.Net.Sockets.4.1.0-beta-23516
Installing System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23516
Installing System.Net.Primitives.4.0.10
Installing System.Private.Networking.4.0.0
Installing System.ComponentModel.EventBasedAsync.4.0.10

dun buildとするとConsoleアプリ同様、エラーがたくさん出るので、project.jsonを編集して、DNXを.NET Core 1.0に限定する。

dnx webすると、libuvにuv_loop_size()というシンボルが見つからないというエラーで怒られる。
apt-get でいれたlibuv.soのreadelfで見てみるとたしかにそんな名前のシンボルはない。
libuvのサイトからソースをダウンロードしてビルドしてみた。


動いた。

 dnx web
info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0]
      User profile is available. Using '/home/shizuku/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
Hosting environment: Production
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

これだとローカルからしかアクセスできないので、project.jsonでWebサーバの引数を変更して、どのアドレスからでもアクセスできるようにする。
下記が最終的なproject.json

$ cat project.json 
{
  "version": "1.0.0-*",
  "userSecretsId": "aspnet5-WebApp1-3e3d5f5f-85cd-4edd-b04d-e55588eb76e2",
  "compilationOptions": {
    "emitEntryPoint": true
  },
  "tooling": {
    "defaultNamespace": "WebApp1"
  },

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.Sqlite": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Dnx.Runtime":"1.0.0-rc1-final",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel --server.urls http://0.0.0.0:5004",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "prepublish": [
      "npm install",
      "bower install",
      "gulp clean",
      "gulp min"
    ]
  }
}

ブラウザからアクセスするといい感じのWebサイトが表示される。
f:id:samehada_shiro:20160518225202p:plain