LoginSignup
22
16

More than 5 years have passed since last update.

MacOSX上でNuGetを使う

Last updated at Posted at 2015-10-07

NuGetとは

.NET環境全般むけのパッケージ管理ソフトのようですね(Mac使いなので詳しくないのです)。

Monoのインストール

まずMonoが必要です。Homebrewでインストールしましょう。

$ brew install mono
(略)
$ mono --version
Mono JIT compiler version 4.2.0 (Stable 4.2.0.179/a224653 Fri Aug 28 13:53:46 PDT 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug
    LLVM:          supported, not enabled.
    GC:            sgen
$

NuGetのインストール

NuGet Gallery」からnuget.exeをダウンロードして、$HOME/binにでも入れましょう。

そして下記のシェルスクリプトを$HOME/bin/nugetとして保存します。

#!/bin/sh
script_dir="$(cd "$(dirname "${BASH_SOURCE:-${(%):-%N}}")"; pwd)"
mono --runtime=v4.0 ${script_dir}/nuget.exe $*

$script_dirはスクリプト自身が配置されているディレクトリを格納する変数で、bash/zsh両対応になっています。

NuGetでMono.Cecilをインストールする

.NETバイナリで遊ぶのにMono.Cecilというライブラリが使えそうなので、NuGetでインストールしてみましょう。まずは情報を確認します。

$ nuget list -Verbosity detailed Mono.Cecil
(略)
Mono.Cecil
 0.9.6.1
 Cecil is a library written by Jb Evain to generate and inspect programs and libraries in the ECMA CIL format. It has full support for generics, and support some debug
 ging symbol format. In simple English, with Cecil, you can load existing managed assemblies, browse all the contained types, modify them on the fly and save back to t
 he disk the modified assembly.
 ライセンス URL: http://opensource.org/licenses/mit-license.php
(略)
$ 

パッケージ名が完全一致していても他のパッケージがヒットしちゃうのが謎ですね。気を取り直してインストールしてみます。

$ nuget install Mono.Cecil
Attempting to gather dependencies information for package 'Mono.Cecil.0.9.6.1' with respect to project '/Users/hnw/work/cecil-test', targeting 'Any,Version=v0.0'
Attempting to resolve dependencies for package 'Mono.Cecil.0.9.6.1' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Mono.Cecil.0.9.6.1'
Resolved actions to install package 'Mono.Cecil.0.9.6.1'
Adding package 'Mono.Cecil.0.9.6.1' to folder '/Users/hnw/work/cecil-test'
Added package 'Mono.Cecil.0.9.6.1' to folder '/Users/hnw/work/cecil-test'
Successfully installed 'Mono.Cecil 0.9.6.1' to /Users/hnw/work/cecil-test
$ find .
.
./Mono.Cecil.0.9.6.1
./Mono.Cecil.0.9.6.1/lib
./Mono.Cecil.0.9.6.1/lib/net20
./Mono.Cecil.0.9.6.1/lib/net20/Mono.Cecil.dll
./Mono.Cecil.0.9.6.1/lib/net20/Mono.Cecil.Mdb.dll
./Mono.Cecil.0.9.6.1/lib/net20/Mono.Cecil.Pdb.dll
./Mono.Cecil.0.9.6.1/lib/net35
./Mono.Cecil.0.9.6.1/lib/net35/Mono.Cecil.dll
./Mono.Cecil.0.9.6.1/lib/net35/Mono.Cecil.Mdb.dll
./Mono.Cecil.0.9.6.1/lib/net35/Mono.Cecil.Pdb.dll
./Mono.Cecil.0.9.6.1/lib/net35/Mono.Cecil.Rocks.dll
./Mono.Cecil.0.9.6.1/lib/net40
./Mono.Cecil.0.9.6.1/lib/net40/Mono.Cecil.dll
./Mono.Cecil.0.9.6.1/lib/net40/Mono.Cecil.Mdb.dll
./Mono.Cecil.0.9.6.1/lib/net40/Mono.Cecil.Pdb.dll
./Mono.Cecil.0.9.6.1/lib/net40/Mono.Cecil.Rocks.dll
./Mono.Cecil.0.9.6.1/lib/net45
./Mono.Cecil.0.9.6.1/lib/net45/Mono.Cecil.dll
./Mono.Cecil.0.9.6.1/lib/net45/Mono.Cecil.Mdb.dll
./Mono.Cecil.0.9.6.1/lib/net45/Mono.Cecil.Pdb.dll
./Mono.Cecil.0.9.6.1/lib/net45/Mono.Cecil.Rocks.dll
./Mono.Cecil.0.9.6.1/lib/sl5
./Mono.Cecil.0.9.6.1/lib/sl5/Mono.Cecil.dll
./Mono.Cecil.0.9.6.1/lib/sl5/Mono.Cecil.Rocks.dll
./Mono.Cecil.0.9.6.1/Mono.Cecil.0.9.6.1.nupkg
$ 

カレントディレクトリ以下にライブラリがインストールされました。

22
16
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
22
16