Wednesday, June 20, 2012

Using NuGet doesn't mean you have to give it away... "Distributing .NET Licensed components using NuGet" - Distributing .NET Licensed components using NuGet

"If you are building components that are licensed using the .NET Licensing Model, you might have been looking for a way to take benefit from NuGet as a distribution mechanism.

If you are unfamiliar with the .NET Licensing Model, I recommend this excellent article providing you with a good introduction and sample code.

No matter what licensing model you use, an application that consumes a licensed component needs to use a mysterious licenses.licx file and set it as an embedded resource. In addition, the license key or .lic file for the licensed component being consumed must be present.

This makes packaging a .NET licensed component slightly different from packaging a simple assembly.


Securing the package?

Ok, so you have a package which is worth something. It contains a licensed fully working version of your component (using this very basic licensing mechanism at least). How do I distribute it? Putting it on is a no-go, as everyone can simply consume it without paying the license fee.

Here's an alternative: create a private NuGet feed on MyGet. Simply give access to those people who paid for it, and secure it for others.

Again, I used a very basic licensing mechanism only to demonstrate how you can embed a file-based license into your NuGet package and pointed out you can secure your feed with granular access instead of worrying about your package. It's up to you to ensure your licensing mechanism doesn't support distributing the licensed package elsewhere! (this proof-of-concept doesn't mitigate this at all, so be warned!)

The code as well as the NuGet package are attached to this blog:


Think using NuGet means you have to give it away? Well if you're using NuGet.Org it does, but remember you don't have to use that feed. You can add other feeds, such as a private feed. So imagine giving your customers the power of NuGet while still being able to provide a commercial, licensed library? That's what caught my eye in this post (that and you just don't see this kind of usage mentioned anywhere...)

1 comment:

Chris Marisic said...

You also missed the most obvious solution. You build your software that it can operate in a trial mode, perhaps with add placements, limited functionality etc.

Then users that purchase your software just need to put the license file inside their bin directory and the tool/component/etc just reads it and goes into licensed state.

This is very similar to how RavenDB uses nuget. It allows developers access to RavenDB for free, and for open source projects. Then users are to purchase licenses to goto production with their app.