We now have a nice clean Release build of our project using a custom MsBuild target. Using this target is important because Teamcity is responsible for the job not just me working on my laptop! Keep that in mind, Teamcity is in charge!
Next step is creating a NuGet package from our build. Again, Teamcity must be able to perform this task.
To create a Nuget package from a directory, we need to create a .nuspec file first.
Creating a nuspec file is easy, navigate to the build directory and open the command from there (shift + right click > open command window here). Now type in:
This command wil create a nuspec file in our build directory. This is just a base file and we need to add some additional information to this file. For example, the content of the package, which is actually the current directory 😉
To add this to the file add the following lines to the file:
<files> <file src="**\*.*" target="website" /> </files>
The full nuspec file looks like:
<?xml version="1.0"?> <package > <metadata> <id>Package</id> <version>1.0.0</version> <authors>Folkert</authors> <owners>Folkert</owners> <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl> <projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl> <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Package description</description> <releaseNotes>Summary of changes made in this release of the package.</releaseNotes> <copyright>Copyright 2015</copyright> <tags>Tag1 Tag2</tags> <dependencies> <dependency id="SampleDependency" version="1.0" /> </dependencies> </metadata> <files> <file src="**\*.*" target="website" /> </files> </package>
We can now test the package. Open the command prompt again and type:
nuget pack Package.nuspec
If all goes well, a nice and clean package is created using the nuspec file
You can open this package using the Nuget Package explorer.