Chris Hammond

DotNetNuke Upgrade and Consulting specialist

News

Thanks for visiting my blog, you can find more about me at ChrisHammond.com. I specialize in all things DotNetNuke

Cool Sites

My domains

Projects

Archives

New Visual Studio 2012 Project Templates for DotNetNuke

dnntemplates-1Earlier this month Microsoft put the bits up for Visual Studio 2012 RTM out on MSDN Subscriber downloads, and during the first two weeks of September they will officially be releasing Visual Studio 2012. I started working with VS2012 late in the release candidate cycle, doing some DNN module development using my templates at http://christoctemplate.codeplex.com.

These templates work fine in Visual Studio 2012 from my testing, but they still face the same problem that they had in Visual Studio 2008 and 2010, you have to install the MSBuild Community Tasks project prior to using the templates, otherwise projects failed to be created.

The other problem with the templates is that they are not easily discoverable, you couldn’t find them in Visual Studio, and they weren’t part of the Visual Studio Gallery. Enter the latest version of my module development templates.

I’ve from the ground up rewritten the project templates, and built them into a VSIX package, a unit of deployment for Visual Studio 2012. While it is true that you can create VSIX files that work in both Visual Studio 2010 and 2012, this project was designed specifically for 2012, and will not likely work in 2010, though I will do some testing and see if I can’t make it work in the future.

Overview of the DotNetNuke Project Templates

There are currently two templates available within the project, one for C# and one for VB.Net. These templates utilize MSBuild for automated packaging of the modules you create, just as previous versions of the templates have. They create compiled modules, meaning stand alone projects, that have their own DLL’s, making them easy to deploy and manage. They differ slightly from the previous version of the templates in that the deployable packages are now in the INSTALL folder within the module, instead of the packages folder.

You can now download new templates directly from within Visual Studio using the Tools\Extensions and Updates menu option. The templates are currently packaged as a Tool in the Visual Studio Gallery, not as individual template projects, so they can only be found by searching for them online, or via the Tools\Extensions and Updates option. As I release new versions of the template project you will be able to upgrade to the later templates using the same Extensions and Updates interface.

In order to start using the templates for you module development within DotNetNuke you will need to perform a number of steps, the first thing being installing the templates (if you don’t have Visual Studio 2012 installed, that would be your first step).

How to Install the Visual Studio 2012 DotNetNuke Project Templates

Installation of the templates is pretty easy, there are multiple ways to do this, choose one of the three options below and perform the steps listed for the option you choose. You only need to do one of these options, not all three.

  1. Install using the Tools\Extensions and Updates menu
    1. Mouse over the Tools menu
    2. Click on Extensions and Updates
    3. Search for DotNetNuke
    4. Choose the Install button for the DotNetNuke Project Templates option
  2. Install manually by downloading the VSIX file from the online gallery
    1. Visit the Visual Studio Gallery – DotNetNuke Project Templates page
    2. Download the VSIX file via the Download link.
    3. Double click on the downloaded file to install the templates.
  3. Install manually by downloading from Codeplex
    1. Download the VSIX file from Codeplex
    2. Double click on the downloaded file to install the templates.

Creating a DotNetNuke Module using the Templates

Once you’ve installed the templates, you can setup a project based on the templates. To do so you should follow the steps below

  1. (you should have this done already) Install Visual Studio 2012
  2. (you should have this done already) Install DotNetNuke Project Templates from the Visual Studio Gallery
  3. Setup your DotNetNuke Development environment following the steps listed here in the Wiki (the templates assume you have your development environment setup at http://dnndev/).
  4. Run Visual Studio 2012 as an Administrator (right click on the shortcut to do so)
  5. File –> New Project
  6. Choose either C# or VB.Net from the Languages section of the new project dialog
  7. Select the DotNetNuke Folder under your preferred language (C# or Visual Basic)
  8. Choose either DotNetNuke C# Compiled Module or DotNetNuke VB.Net Compiled Module for your project template
  9. For the new project creation screen using the following settings dnntemplates-2
    1. Name: ModuleName (something unique here, example DNNTaskManager)
    2. Location: c:\websites\dnndev\desktopmodules\ (this assumes you setup your development environment as instructed in Step 3)
    3. Solution: Create new solution
    4. Create directory for solution : Unchecked (this will cause path problems if checked, the templates assume the SLN is in the same folder as the project file)
    5. Add to source control: Unchecked (I typically get my project running before adding it to source control)
    6. Click OK

This will create a folder under c:\websites\dnndev\desktopmodules\ModuleName and should contain all of the files necessary for your module, including the Solution. There are a couple of next steps just to finalize the process, these steps are documented in the Documentation\Documentation.html file, which should open up automatically in Visual Studio after your project gets created, follow these steps to configure the final project properties, then you are ready to build/deploy your module. You can delete the documentation folder once you have completed those steps.

To build and install your module, you should switch to Release mode in Visual Studio and then choose Build Solution from the Build menu. This will compile and package your module for distribution.

The module will be packaged into the INSTALL folder inside of desktopmodules\ModuleName. This is different a location from the prior version of my templates.

From there you can install the SOURCE package into the Host/Extension page of your development environment, that will install the module within DNN and allow you to place it on a page and start working with module. For more information check out the Task Manager tutorial series

How to Customize the Templates

You may want to customize these templates in order to define your own namespace, email address, and domain name for the project properties. In order to customize these templates, you will want to download the Source for the DNNTemplates project, make changes, and recompile that project to create your own VSIX file, you will then use this VSIX file to install your custom templates. I do recommend that you change the name of the templates using the VSIX manifest interface in Visual Studio. You can follow the steps below to customize and package your own templates.

  • Install Visual Studio 2012 (currently available from MSDN downloads)
  • Install Visual Studio 2012 SDK (currently available from MSDN downloads)
  • Download the VSIX Source Code project from Codeplex (click here to go to codeplex
  • Extract the package to a folder (I use c:\projects\dnntemplates\vsix)
  • Open the Solution in the VSIX folder (dnntemplates.sln) in Visual Studio 2012
  • Open the source.extension.vsixmanifest file (it should default into the designer)
    • Change the Product Name to something other than DotNetNuke Project Templates
  • Expand the CSharp-Template (mirror process for VB-Template to modify the VB template)
  • Open the DotNetNuke 6 C Compiled Module.vstemplate (or DotNetNuke 6 VB Compiled Module.vstemplate) file
    • Change the Name found within TemplateData in the vstemplate file, I would suggest relating this to the name of your company.
    • Find the CustomParameters section and modify the Values of any of the necessary parameters.
  • Now you will need to compile the DNNTemplates solution in Release mode, this will generate a new VSIX file under the vsix/dnntemplates/bin/release folder.
  • Deploy the VSIX file by double clicking on the file (found in the dnntemplates/bin/release folder).

What’s Next for the Project?

My intention is to create some additional templates to be included within the DotNetNuke Project Templates package, likely one for doing custom Skin Development, and maybe even some for other types of DNN Extensions. I will also be adding "ItemTemplates” into the distribution in the future. I will most likely also list both the C# and VB.NET templates as individual templates so they can be found searching for a simple project template, rather than having to search for a Tool as they are now, though I will see if there are other options for making them discoverable.

If you have any feedback on these templates, please feel free to post on the Discussion portion of the Codeplex project, I’m always open to ideas that will improve upon these templates.

Comments

olala said:

I have installed vs express 2012 for web and I failed to install dotnetnuke projects in accordance with text above. I was told that supported product was vs pro ver 11.0. Do you intend to make it possible to use the express version?

# September 3, 2012 6:09 AM

Chris Hammond said:

Olala these won't work with VS2012 Express at this point, I will have to look into why that is later this fall, but it will be a few weeks due to my work schedule and travelling.

Chris

# September 4, 2012 5:17 AM

David said:

A very impressive and much needed Template extention for developing for DNN 6 with VS2012. I would really like to see one for creating Skin Packages in the near future.

# October 5, 2012 9:57 AM

Chris Hammond said:

Thanks David, I hope to work on a Skin template later this year

# October 5, 2012 10:31 AM