development development - 4 months ago 17
C# Question

Best practice when developing a C# Library for use in multiple solutions/projects

Long time lurker, first time poster, so apologies if I'm asking the wrong type of question here.

I have a project with C# classes and functions that I use with various C# projects. Let's call it "KitchenSink". As I work on various projects, I add, remove, and modify parts of KitchenSink. Maybe I'm working on an app that organizes CDs, so I'll add some sorting routines to KitchenSink. Then maybe decide to write an app that emails stuff, so I add some messaging stuff to KitchenSink.

Currently I add the most recent version of KitchenSink project to whatever solution I'm working on, and then work on that solution. This means I can't really start another solution, because then I'm working on another version of KitchenSink. Hopefully this makes sense.

What's the best way to work with a library like this, across multiple projects/solutions, and keep one version for all of them? I had the crazy idea of putting all of my various projects, along with KitchenSink, into one solution. That way when I modify KitchenSink, I'll know what breaks. And when I am ready to release a project, I can just copy that and KitchenSink to a new solution.

This is probably the worst question ever. Sorry.

Answer

This is a problem that is solved by package managers.

Using Nuget, you can keep multiple versions of your application available, and consumers of your nuget package will select which version they want. When an application needs a new version of KitchenSink, it will have to be manually and purposefully upgraded via Nuget.

Personally, I've had success using the free version of MyGet to hook into my github account and create and maintain Nuget packages for me.