NuGet Packup is a tool to create a NuGet package for the project, with getting values from AssemblyInfo.
NuGet Packup は、アセンブリの情報 (主に AssemblyInfo.cs) から必要な値を取得して、
NuGet パッケージを作成するためのツールです。
Visual Studio でプロジェクトを右クリックして [Nuget パッケージの管理] から NuGet Packup を検索するか、
またはパッケージ マネージャー コンソールで
Install-Package Keiho.Tools.NuGetPackup
を実行すればインストールできます。
NuGet Packup をインストールすると、NuGet.CommandLine も同時にインストールされます。
インストールが完了すると、次のファイルがプロジェクトに追加されます。
- NuGetPackup.exe
- Package.nuspec.xml
Package.nuspec.xml は、.nuspec ファイルのテンプレートとして使用されます。
Package.nuspec.xml にある
NuGet パッケージを作成するために必要なパラメーターを表します。
各プレースホルダーに代入される値は、次の表の場所から取得されます。太字は必須項目です。
AssemblyInfo.cs に最初から記述されている AssemblyFileVersion 属性などのほかにも、
AssemblyMetadata 属性を利用して値を指定しておきます。
プレースホルダー | 値の取得先 |
---|---|
プロジェクトのプロパティのアセンブリ名 | |
AssemblyFileVersion 属性 | |
AssemblyTitle 属性 | |
AssemblyDescription 属性 | |
AssemblyCompany 属性 | |
AssemblyCopyright 属性 | |
AssemblyMetadata 属性、キー ProjectUrl | |
AssemblyMetadata 属性、キー LicenseUrl | |
AssemblyMetadata 属性、キー Tags | |
AssemblyMetadata 属性、キー ReleaseNotes |
必要であれば、.nuspec ファイルの仕様に従って Package.nuspec.xml を編集します。
例えば、
<frameworkAssemblies>
: .NET Framework アセンブリへの参照<dependencies>
: パッケージへの参照<files>
: パッケージに含めるファイル
などがよく使われると思います。
既定では、bin\Release にあるファイルをライブラリとして追加します。
NuGetPackup.exe を実行すれば、NuGet パッケージが作成されます。
ただし、先にプロジェクトの Release ビルドを実施しておく必要があります。
- .NET Framework 4.5 以降
拡張子が .nuspec であるファイルを NuGet パッケージに含めることができないため、
ファイル名を Package.nuspec.xml としています。