Two weeks ago I started migrating all my .NET projects to Nuget
, you can read more about it in my previous post
After I was done with my OSS projects
, I decided to share the goodness with some of my clients and then came to realize a few issues with my "stop storing dependencies in the repository
First, many of the dependencies can't be published to the public nuget.org server. That means that we need to find a way to store them locally.
: Install local nuget feed.
Why a local Nuget feed is a good idea
Having a local feed allows your company leverage all the benefits of package management internally.
Plus you can use it to cache common used packages in case you have issues downloading them.
How to do this you ask? Well, is not as straightforward as I hoped. Luckily I had the help of @davidalpert
to fight IIS configuration and @ferventcoder
to answer all our questions.
After approximately 3 weeks of tinkering with the server, David managed to make it work. (Kudos, yay!)
Here are a few links to follow in order to install the server locally:
- URL should be http://yourserver:port/dataservices/packages.svc
- Add the .nupkg as mime type with application/zip
- Remember that the new server is not an MVC application
- Be patient, very patient...
I got the server running, now what?
Well now we have to tackle a different problem. I found that some of the projects are using libraries that are not yet published to the public feed.
Though I could package and publish them (I have done so with Structuremap.Automocking
and others), some of them are a bit out of date and others are the result of downloading the source, modifying it and compiling it locally.
Either case, I thought that I'd like an easy way of packaging and publishing these packages to the local feed in order to keep using them.
Doing so is also a great solution if you don't have the time to review if an upgrade would work, or is to risky to do it.
If you read my previous post you already know that I'm using Albacore
to generate the nuspec file, build the package, etc.
My first thought was to use those tasks for each of the packages in need to create. And I started to do so.
Rake again and again
After creating a rakefile, copying the libs, etc for the third time, my laziness sense
(similar to spider sense without the awesome
and the great responsibility
thing) started to tingle indicating that should be a way of avoiding this repetitive task.
- Copy the assemblies to a lib folder
- Generate the nuspec with the name of the library and the version
- Compile the nuspec and create the package
- Copy the package to the destination to be served by the local feed
Instead of writing one rakefile per package, why not just add parameters to the rakefile so I can call it from command line specifying:
- Name of the package
- Version of the package
- Folder where to get all the assemblies
And voila! Here
is the result, I hope you find it useful.
To use it, you will have to type something like this:
rake deploy:publish[AvalonDock, 1.0, "c:\project\lib\avalondock"]
Are you doing anything else cool with nuget? Please share!