개요

설치

Install the .NET Version Manager(DNVM)

$ curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
Downloading dnvm as script to '/Users/onlydel/.dnx/dnvm'

Appending source string to /Users/onlydel/.bash_profile
Appending source string to /Users/onlydel/.zshrc
Type 'source /Users/onlydel/.dnx/dnvm/dnvm.sh' to start using dnvm
Onlydel-MacBook-Pro:~ onlydel$ dnvm upgrade -r coreclr
Determining latest version
Latest version is 1.0.0-beta7
Downloading dnx-coreclr-darwin-x64.1.0.0-beta7 from https://www.nuget.org/api/v2
Download: https://www.nuget.org/api/v2/package/dnx-coreclr-darwin-x64/1.0.0-beta7
######################################################################## 100.0%
Installing to /Users/onlydel/.dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-beta7
Adding /Users/onlydel/.dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-beta7/bin to process PATH
Setting alias 'default' to 'dnx-coreclr-darwin-x64.1.0.0-beta7'
Onlydel-MacBook-Pro:~ onlydel$ dnvm upgrade -r mono
It appears you don't have Mono available. Remember to get Mono before trying to run  application.
Determining latest version
Latest version is 1.0.0-beta7
Downloading dnx-mono.1.0.0-beta7 from https://www.nuget.org/api/v2
Download: https://www.nuget.org/api/v2/package/dnx-mono/1.0.0-beta7
######################################################################## 100.0%
Installing to /Users/onlydel/.dnx/runtimes/dnx-mono.1.0.0-beta7
Adding /Users/onlydel/.dnx/runtimes/dnx-mono.1.0.0-beta7/bin to process PATH
Updating alias 'default' to 'dnx-mono.1.0.0-beta7'

Install the .NET Execution Environment (DNX)

.NET Core 설치하기

$ dnvm upgrade -r coreclr
Determining latest version
Latest version is 1.0.0-beta7
Downloading dnx-coreclr-darwin-x64.1.0.0-beta7 from https://www.nuget.org/api/v2
Download: https://www.nuget.org/api/v2/package/dnx-coreclr-darwin-x64/1.0.0-beta7
######################################################################## 100.0%
Installing to /Users/onlydel/.dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-beta7
Adding /Users/onlydel/.dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-beta7/bin to process PATH
Setting alias 'default' to 'dnx-coreclr-darwin-x64.1.0.0-beta7'

cross platform .net framework - mono설치

$ dnvm upgrade -r mono
It appears you don't have Mono available. Remember to get Mono before trying to run  application.
Determining latest version
Latest version is 1.0.0-beta7
Downloading dnx-mono.1.0.0-beta7 from https://www.nuget.org/api/v2
Download: https://www.nuget.org/api/v2/package/dnx-mono/1.0.0-beta7
######################################################################## 100.0%
Installing to /Users/onlydel/.dnx/runtimes/dnx-mono.1.0.0-beta7
Adding /Users/onlydel/.dnx/runtimes/dnx-mono.1.0.0-beta7/bin to process PATH
Updating alias 'default' to 'dnx-mono.1.0.0-beta7'

설치확인

$ dnvm list

Active Version              Runtime Architecture OperatingSystem Alias
------ -------              ------- ------------ --------------- -----
       1.0.0-beta7          coreclr x64          darwin
  *    1.0.0-beta7          mono                 linux/osx       default

yeomen 설치

/usr/local/bin 디렉토리에에 쓰기 권한 있어야 한다.

$ npm install -g yo

> spawn-sync@1.0.13 postinstall /usr/local/lib/node_modules/yo/node_modules/cross-spawn/node_modules/spawn-sync
> node postinstall

/usr/local/bin/yo -> /usr/local/lib/node_modules/yo/lib/cli.js

> yo@1.4.8 postinstall /usr/local/lib/node_modules/yo
> yodoctor


Yeoman Doctor
Running sanity checks on your system

✔ Global configuration file is valid
✔ NODE_PATH matches the npm root
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version

Everything looks all right!
yo@1.4.8 /usr/local/lib/node_modules/yo
├── titleize@1.0.0
├── array-uniq@1.0.2
├── figures@1.4.0
├── async@1.4.2
├── humanize-string@1.0.1 (decamelize@1.0.0)
├── opn@3.0.2 (object-assign@3.0.0)
├── user-home@2.0.0 (os-homedir@1.0.1)
├── yeoman-character@1.0.1 (supports-color@1.3.1)
├── findup@0.1.5 (commander@2.1.0, colors@0.6.2)
├── string-length@1.0.1 (strip-ansi@3.0.0)
├── sort-on@1.2.2 (arrify@1.0.0, dot-prop@2.2.0)
├── chalk@1.1.1 (escape-string-regexp@1.0.3, ansi-styles@2.1.0, supports-color@2.0.0, strip-ansi@3.0.0, has-ansi@2.0.0)
├── repeating@1.1.3 (is-finite@1.0.1)
├── update-notifier@0.5.0 (is-npm@1.0.0, latest-version@1.0.1, semver-diff@2.0.0)
├── root-check@1.0.0 (downgrade-root@1.1.0, sudo-block@1.2.0)
├── configstore@1.2.1 (os-tmpdir@1.0.1, object-assign@3.0.0, graceful-fs@4.1.2, xdg-basedir@2.0.0, uuid@2.0.1, osenv@0.1.3, write-file-atomic@1.1.3, mkdirp@0.5.1)
├── yosay@1.0.5 (ansi-regex@1.1.1, word-wrap@1.1.0, ansi-styles@2.1.0, strip-ansi@2.0.1, pad-component@0.0.1, taketalk@1.0.0, minimist@1.2.0, string-width@1.0.1)
├── inquirer@0.9.0 (ansi-regex@2.0.0, strip-ansi@3.0.0, cli-width@1.0.1, rx-lite@2.5.2, through@2.3.8, readline2@0.1.1, run-async@0.1.0)
├── got@4.2.0 (lowercase-keys@1.0.0, is-stream@1.0.1, timed-out@2.0.0, is-redirect@1.0.0, prepend-http@1.0.3, is-plain-obj@1.0.0, object-assign@3.0.0, unzip-response@1.0.0, node-status-codes@1.0.0, parse-json@2.2.0, create-error-class@2.0.1, pinkie-promise@1.0.0, duplexify@3.4.2, read-all-stream@3.0.1)
├── npm-keyword@1.2.0 (got@3.3.1, registry-url@3.0.3)
├── package-json@1.2.0 (got@3.3.1, registry-url@3.0.3)
├── fullname@1.1.1 (npmconf@2.1.2)
├── cross-spawn@0.4.1 (lru-cache@2.7.0, spawn-sync@1.0.13)
├── meow@3.4.2 (trim-newlines@1.0.0, loud-rejection@1.0.0, object-assign@4.0.1, minimist@1.2.0, camelcase-keys@1.0.0, redent@1.0.0, read-pkg-up@1.0.1, normalize-package-data@2.3.4)
├── lodash@3.10.1
├── yeoman-environment@1.2.7 (diff@1.4.0, escape-string-regexp@1.0.3, log-symbols@1.0.2, text-table@0.2.0, untildify@2.1.0, debug@2.2.0, grouped-queue@0.3.0, mem-fs@1.1.0, globby@2.1.0, inquirer@0.8.5)
├── insight@0.6.0 (object-assign@2.1.1, async@0.9.2, lodash.debounce@3.1.1, tough-cookie@1.2.0, os-name@1.0.3, inquirer@0.8.5, request@2.64.0)
└── yeoman-doctor@1.4.0 (object-values@1.0.0, log-symbols@1.0.2, user-home@1.1.1, each-async@1.1.1, semver@4.3.6, bin-version-check@2.1.0, twig@0.8.2)

스케폴딩을 위해 OmniSharp generator설치

yo를 이용해서 개발틀을 만들어준다.

$ npm install -g generator-aspnet
generator-aspnet@0.0.75 /usr/local/lib/node_modules/generator-aspnet
├── vs_projectname@1.0.2
├── uuid@2.0.1
├── chalk@1.1.1 (ansi-styles@2.1.0, escape-string-regexp@1.0.3, supports-color@2.0.0, has-ansi@2.0.0, strip-ansi@3.0.0)
├── yosay@1.0.5 (ansi-styles@2.1.0, ansi-regex@1.1.1, word-wrap@1.1.0, strip-ansi@2.0.1, pad-component@0.0.1, minimist@1.2.0, taketalk@1.0.0, string-width@1.0.1, repeating@1.1.3)
├── chai@1.10.0 (assertion-error@1.0.0, deep-eql@0.1.3)
└── yeoman-generator@0.19.2 (diff@1.4.0, read-chunk@1.0.1, detect-conflict@1.0.0, yeoman-welcome@1.0.1, xdg-basedir@1.0.1, user-home@1.1.1, rimraf@2.4.3, async@0.9.2, mime@1.3.4, text-table@0.2.0, dargs@4.0.1, class-extend@0.1.1, debug@2.2.0, shelljs@0.4.0, nopt@3.0.4, cross-spawn@0.2.9, mkdirp@0.5.1, istextorbinary@1.0.2, run-async@0.1.0, mem-fs-editor@1.2.3, through2@0.6.5, cli-table@0.3.1, underscore.string@3.2.2, yeoman-assert@1.0.0, glob@5.0.15, findup-sync@0.2.1, yeoman-environment@1.2.7, github-username@1.1.1, sinon@1.17.1, dateformat@1.0.11, pretty-bytes@1.0.4, lodash@3.10.1, inquirer@0.8.5, download@4.2.1, gruntfile-editor@1.0.0, html-wiring@1.2.0)

스케폴딩(Scheffolding)

  1. 솔루션을 위한 폴더를 만든다.

     $ mkdir -p ~/AspNet/MyFirstDnxApp
  2. 솔루션 폴더에 global.json파일을 만들고 아래 내용을 넣는다.

     {
       "sdk": {
         "version": "1.0.0-beta7"
       }
     }
  3. Application type선택: 위,아래 화살표키로 선택후 엔터

     $ yo aspnet
    
          _-----_
         |       |    .--------------------------.
         |--(o)--|    |      Welcome to the      |
        `---------´   |   marvellous ASP.NET 5   |
         ( _´U`_ )    |        generator!        |
         /___A___\    '--------------------------'
          |  ~  |
        __'.___.'__
      ´   `  |° ´ Y `
    
     ? What type of application do you want to create? (Use arrow keys)
     ❯ Empty Application
       Console Application
       Web Application
       Web Application Basic [without Membership and Authorization]
       Web API Application
       Nancy ASP.NET Application
       Class Library
       Unit test project
  4. Application Name 입력

     ? What's the name of your ASP.NET application? (EmptyApplication)
      create dnxFirstApp/.gitignore
      create dnxFirstApp/hosting.ini
      create dnxFirstApp/Startup.cs
      create dnxFirstApp/project.json
      create dnxFirstApp/Dockerfile
      create dnxFirstApp/wwwroot/README.md
    
     Your project is now created, you can use the following commands to get going
       cd "EmptyApplication"
       dnu restore
       dnu build (optional, build will also happen when it's run)
       dnx kestrel

실행

터미널로 EmptyApplication 디렉토리로 이동 dnu restore를 실행 한다.

$ dnu restore
Microsoft .NET Development Utility Mono-x64-1.0.0-beta7-15532

  GET https://api.nuget.org/v3/index.json
  OK https://api.nuget.org/v3/index.json 1119ms
Restoring packages for /Users/onlydel/AspNet/src/EmptyApplication/project.json
  GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnet.server.iis/index.json
  GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnet.server.weblistener/index.json
  GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnet.server.kestrel/index.json
  OK https://api.nuget.org/v3-flatcontainer/microsoft.aspnet.server.iis/index.json 1119ms
  GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnet.server.iis/1.0.0-beta7/microsoft.aspnet.server.iis.1.0.0-beta7.nupkg
  
  ...

Installing System.Reflection.Emit.4.0.0
Installing System.Reflection.Emit.ILGeneration.4.0.0
Installing System.Reflection.TypeExtensions.4.0.0
Installing System.Diagnostics.Tracing.4.0.21-beta-23225
Installing System.Threading.Thread.4.0.0-beta-23225
Installing System.Diagnostics.TraceSource.4.0.0-beta-23225
Installing System.Reflection.Extensions.4.0.1-beta-23225
Installing Microsoft.Win32.Registry.4.0.0-beta-23225
Installing System.Diagnostics.Process.4.0.0-beta-23225
Installing System.Security.SecureString.4.0.0-beta-23225
Installing System.Security.Claims.4.0.0
Installing System.Net.NetworkInformation.4.0.10-beta-23123
Installing System.Private.Networking.4.0.0
Writing lock file /Users/onlydel/AspNet/src/EmptyApplication/project.lock.json
Restore complete, 201807ms elapsed

NuGet Config files used:
    /Users/onlydel/.config/NuGet/NuGet.Config

Feeds used:
    https://api.nuget.org/v3-flatcontainer/

Installed:
    128 package(s) to /Users/onlydel/.dnx/packages

혹시 다음과 같은 에러가 나면 mono설치를 다시 해 준다.

/Users/onlydel/.dnx/runtimes/dnx-mono.1.0.0-beta7/bin/dnx: line 14: exec: mono: not found
  • brew로 mono 설치

      $ brew install mono
      ==> Downloading https://homebrew.bintray.com/bottles/mono-4.2.0.179.el_capitan.bottle.tar.gz
      ######################################################################## 100.0%
      ==> Pouring mono-4.2.0.179.el_capitan.bottle.tar.gz
      ==> Caveats
      To use the assemblies from other formulae you need to set:
        export MONO_GAC_PREFIX="/usr/local"
      ==> Summary
      🍺  /usr/local/Cellar/mono/4.2.0.179: 1010 files, 184M

dnx kestrel을 실행 하면 웹 애플리케이션이 시작된다.

$ dnx kestrel
Application started. Press Ctrl+C to shut down.

브라우저에서 localhost:5000으로 접속하면 Hello World!!를 볼수 있다.


참조