Creating Nuget Package & Nuget Server

What is packaged?

OctoPack is smart enough to only package files required for deployment. If you are packaging a Windows Service or Console application, then it will package all of the output files in the bin\Release folder (assuming you have done a release build).

Octopack

This utility help you to create the NuGet Package of your project through Visual Studio. It is open source and available through NuGet package Installer.

Installing OctoPack:-

You can install it using the NuGet package installer

octopack1

OctoPack should only be installed on projects that you are going to deploy – that means the console application projects, Windows Service projects, and

ASP.NET web applications. Unit tests, class libraries, and other supporting projects wouldn’t be selected.

octopack2

Building packages

To have OctoPack create a NuGet package from your build, set the RunOctoPack MSBuild property to true. For example, if you are compiling from the command line, you might use:

msbuild MySolution.sln /t:Build /p:RunOctoPack=true

After the build completes, in the output directory you will find a NuGet package. This package is ready to be deployed using your Octopus Deploy server

Adding a NuSpec

A .nuspec file describes the contents of your NuGet package. OctoPack automatically creates one if you haven’t provided one, by guessing some of the settings from your project. But you may wish to provide your own simple .nuspec file to your project. The file name should match the name of your C# project – for example, Sample.Web.nuspec if your ASP.NET project is named Sample.Web. The nuspec file needs to be in the same directory as your csproj file.

 

Here is an example of the .nuspec file contents:

Sample NuSpec file

What is packaged?
OctoPack is smart enough to only package files required for deployment. If you are packaging a Windows Service or Console application, then it will package all of the output files in the bin\Release folder (assuming you have done a release build).

<?xml version=”1.0″?>

<package xmlns=”http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd”&gt;
<metadata>
<id>Sample.Web</id>
<title>Your Web Application</title>
<version>1.0.0</version>
<authors>Your name</authors>
<owners>Your name</owners>
<licenseUrl>http://yourcompany.com</licenseUrl&gt;
<projectUrl>http://yourcompany.com</projectUrl&gt;
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A sample project</description>
<releaseNotes>This release contains the following changes…</releaseNotes>
</metadata>
</package>

What is packaged?
OctoPack is smart enough to only package files required for deployment. If you are packaging a Windows Service or Console application, then it will package all of the output files in the bin\Release folder (assuming you have done a release build).

If you need to include other files in your package for deployment, use the Visual Studio properties panel to set the Copy to Output Directory attribute to Copy always.

Web applications require additional files to run, such as Razor/ASPX files, configuration files, and assets such as images, CSS and JavaScript files. When packaging a web application, OctoPack will include any files marked with the Build Action set to Content in the Solution Explorer properties window:

octopack3

OctoPack determines whether a project is a web application or not based on whether it finds a web.config file.

(Note: OctoPack won’t run web.config transformation files, because these will be run as part of the deployment instead. OctoPack also automatically excludes Web.Debug.config from the package)

If you need to go beyond this and include additional files, you can do so using the <files> element in your custom NuSpec file. For example:

<files>
<file src="bin\*.dll" target="bin" />
<file src="Content\*.css" target="Content" />
</files>

If the <files> section exists, OctoPack by default won’t attempt to automatically add any extra files to your package, so you’ll need to be explicit about which files you want to include. You can override this behavior with

 /p:OctoPackEnforceAddingFiles=true

To create nugget package

msbuild C:\Amit\SlowCheetahExample\SlowCheetahExample.sln /t:Build /p:RunOctopack=true

References

http://docs.octopusdeploy.com/display/OD/Using+OctoPack

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.