Simple Nuget
Bored by the thousands of way to build nuget packages automatically under VS2010... I started my quest too.
And after creating my own php implementation of nuget server, i was finally able to find a -simple- way to solve everything without external tools or messing around with weird packages.
I concluded with the following steps:
- Download and install nuget from "Microsoft TM website( )":http://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c
- Fill up the AssemblyInfo with consistent atttributes
- Adding on the post-build step the following command to put all packages into a given directory. Note the -Prop parameters, it's used to add extra parameters to replace into the nuspec file
mkdir "$(SolutionDir)NugetPackages"
$(SolutionDir).nuget\nuget pack "$(ProjectPath)" -OutputDirectory "$(SolutionDir)NugetPackages"
-Prop "Configuration=$(ConfigurationName);Platform=$(PlatformName)"
- Created the nuspec file with the same name of the project in the same directory of the .csproj file. Note that
** The $configuration$ variable is taken by the command line
** Nuget will automatically add the dependencies founded into the packages.config founded into the project folder. The sample nuspec down there for example needs to include log4net v. 2.0.0 but this reference is automatically discovered!
** Nuget will automatically add the reference to the assembly generated by the given project but NOT the assembly that it reference, so i added the ExtDll.dll into the files needed to deploy this package
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>$id$</id>
<version>$version$</version>
<title />
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<dependencies>
<group targetFramework=".NETFramework4.0">
<dependency id="ZakCoreUtilsInterfaces" version="$version$" />
<dependency id="ZakCoreUtils" version="$version$" />
</group>
</dependencies>
</metadata>
<files>
<file src="bin\$configuration$\ExtDll.dll" target="lib\net40\ExtDll.dll" />
</files>
</package>
- Then to push the package you could easily do it following the command line below where
** foo.nupkg is the package with full path
** 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a is the token given to you by the nuget server mantainer
** http://customsource/ is the address of the nuget server
nuget push foo.nupkg 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -s http://customsource/
Happy Nugetting!
Last modified on: January 03, 2014