How to create lightweight reusable source code with NuGet

Sometimes, you just have a reusable helper that you bring in to every project (i.e. an argument validation thingy, or the static reflection stuff, useful extension methods, and so on). You don't always need them all, they are generally single-file utilities, and having a Common.dll looks overkill or dumb.

Loose source file sharing has always been problematic, though: no packaging and versioning mechanism (unlike an assembly), hard to integrate with source control systems (SVN has external repository mappings, but nothing like that exists in TFS or Mercurial, AFAIK), and so on. I tried source files reuse before, with somewhat poor results.

In a recent project I wanted to reuse (again) that darn useful Guard.cs file. But I set to do it differently this time, and see if my "dream" for lightweight loose source file reuse could still be achieved.

Two key technologies enable some pretty cool and robust source file reuse nowadays:

  • NuGet: unless you've been living under a rock, you probably heard all the ...

Read full article

No Comments