On the Nancy templates for Visual Studio

A while back we introduced Nancy templates for Visual Studio, which gave you the ability to create a new Nancy project that has Nancy added out-of-the-box. This meant no more creating an empty ASP.NET web application, removing all those pesky project references and installing the Nancy nugets, just to get up and running.

Unfortunately we have not been able to update these template with every new release of Nancy, which means you have had to update the Nancy Nugets to make sure you where using the latest build.

Believe me when I tell you that this has not been out of laziness, but rather the instinct to survive, but hopefully we've taken a couple of important decisions to remedy this in the future

So what does it take to create a template (with Nuget support)?

As it turns out, quite a lot actually. It definitely takes a lot more than I anticipated and it is quite obvious that that tooling was not created for performing anything else than trivial template tasks.

Here is basically the steps we have to do extract the template from the projects

  • Start Visual Studio and load the solution
  • File -> Export Template
  • Make sure "Project Template" is selected on the first page of the Wizard + select the correct project in the drop-down
  • Fill out template name, description, icon and preview image (either use the Browse button or copy/paste the path)
  • Export the template to the default (non-changeable) location
  • Go the output location
  • Break open the zip file
  • Open the MyTemplate.vstemplate file (yes, they all get this name when you export)
  • Modify the "DefaultName" element
  • Modify all .cs files and so that the namespace declarations (and other things you need to like assembly name etc) so it uses the $safeprojectname$ placeholder
  • Insert the node (and sub-nodes), which contains information on which Nuget packages to install + versions
  • Zip up the content again (making sure you get the folder structure right)
  • Copy the zip to the right location in our VSIX project (ProjectTemplates\CSharp\Web)
  • Go back into visual studio, include the zip in the project, edit it's build action to "content" and configure it to be included in the VSI

We have to repeat these things for each and everyone of the templates we ship. We currently have 9 C# templates and that is already quite a work load to do for each new release of Nancy we put out.

If that was not enough, the awesome Ryan Riley (@panesofglass on Twitter) and Christiaan Baes (@chrissie1 on Twitter) send us pull-requests for adding F# and VB.NET templates.

This pushed the number of template count a bit into the 20's and this is pretty much where our work efforts kept coming to a grinding halt. The sheer amount of work required to get these new templates out is what made me start (and abandon) the work several times.

Yesterday, me and @grumpydev took the decision to only support the C# templates moving forward. We really appreciate the work put in by Ryan and Christiaan, but we came to the conclusion that the vast majority of our users are C# users and the added workload could not justify us supporting F# and VB.NET.

That said, we would really like to thank Ryan and Christiaan for their work and support and would like to encourage them to either support the templates themselves, or see someone else in the community step up and do it for them (or why not team up with them if these templates are in your interest?)

Moving forward

By deciding to only focus on the C# templates, we reduce our workload by a huge chunk moving forward and thanks to the awesome Mattias Karlsson (@devlead on Twitter), whom sent us a pull-request last night with the C# templates updated to 0.22.1, we expect to have these in your Visual Studio any day now!

We have also decided to look into the Sidewaffle project as an alternative to the VSIX distribution. If anyone would like to offer their Sidewaffle expertise or just help out, please let us know

Thanks for your patience!

"This post was aggregated from http://thecodejunkie.com/2013/11/15/on-the-nancy-templates-for-visual-studio/ and all comments should be submitted on the original post"