- Mac OSX El Capitan 10.11.1
- mono 4.2.1
$ brew install mono
$ mono --version
Mono JIT compiler version 4.2.1 (explicit/6dd2d0d Fri Nov 6 12:25:19 EST 2015)
$ export MONO_MANAGED_WATCHER=false
F# パッケージ取得ツールである nuget.exe の呼び出しスクリプトを作成する
$ wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
$ sudo mv nuget.exe /usr/local/bin
$ touch nuget
$ vim nuget
#!/bin/sh
script_dir="$(cd "$(dirname "${BASH_SOURCE:-${(%):-%N}}")"; pwd)"
mono --runtime=v4.0 ${script_dir}/nuget.exe $*
$ chmod 777 nuget
$ sudo mv nuget /usr/local/bin
$ touch nugetinstall
$ vim nugetinstall
#!/bin/sh
nuget install $* -OutputDirectory packages -ExcludeVersion
$ chmod 777 nugetinstall
$ sudo mv nuget /usr/local/bin
$ nugetinstall FAKE
...
Successfully installed 'FAKE 4.11.3' to packages
$ tree
.
└── packages
└── FAKE
├── FAKE.nupkg
├── docs
│ ├── RELEASE_NOTES.html
...
F# パッケージ管理ツールである paket.exe の呼び出しスクリプトを作成する
$ touch paket
$ vin paket
#!/bin/sh
paket_path=./packages/Paket/tools/paket.exe
if [ ! -e $paket_path ]; then
echo "Paket installing..."
nugetinstall Paket
fi
mono $paket_path $*
$ chmod 777 paket
$ sudo mv paket /usr/local/bin
$ paket init
//依存設定
$ vim paket.dependencies
source https://nuget.org/api/v2
nuget Suave
$ paket install
$ tree .
.
├── packages
│ ├── FSharp.Core
│ │ ├── FSharp.Core.4.0.0.1.nupkg
...
│ ├── Paket
│ │ ├── Paket.nupkg
...
│ └── Suave
│ ├── Suave.0.33.0.nupkg
...
F# ビルドツールである fake.exe の呼び出しスクリプトを作成する
$ touch fake
$ vim fake
#!/bin/sh
fake_path=./packages/FAKE/tools/FAKE.exe
if [ ! -e $fake_path ]; then
echo "FAKE installing..."
nugetinstall FAKE
fi
mono $fake_path $*
$ chmod 777 fake
$ sudo mv fake /usr/local/bin
Paketでライブラリ取得後に、Fake起動するスクリプトを作成
$ touch fakerun
$ vim fakerun
#!/bin/sh
if [ ! -e paket.lock ]; then
paket install
else
paket restore
fi
fake --printdetails --fsiargs $*
$ chmod 777 fakerun
$ sudo mv fakerun /usr/local/bin
依存ライブラリの設定と取得
$ paket init
$ vim paket.dependencies
source https://www.nuget.org/api/v2
nuget FAKE
nuget Suave
nuget FSharp.Compiler.Service
$ paket install
Webアプリの最小限コード
$ touch suave.fsx
$ vim suave.fsx
#r "packages/Suave/lib/net40/Suave.dll"
#r "packages/FAKE/tools/FakeLib.dll"
open Fake
open System
open System.IO
open Suave
open Suave.Http
open Suave.Web
open Suave.Types
open Suave.Http.Successful
Target "run" (fun _ ->
startWebServer defaultConfig (OK "Hello")
)
RunTargetOrDefault "run"
実行する
$ fakerun suave.fsx
[I] 2015-12-23T04:32:09.6107750Z: listener started in 43.286 ms with binding 127.0.0.1:8083 [Suave.Tcp.tcpIpServer]
http://localhost:8083/ にアクセス!