UPDATE: 1/25/2013 - There is a new release for the VS2012 templates, be sure to read that blog announcement if you want to use the templates.
Earlier 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.
- Install using the Tools\Extensions and Updates menu
- Mouse over the Tools menu
- Click on Extensions and Updates
- Search for DotNetNuke
- Choose the Install button for the DotNetNuke Project Templates option
- Install manually by downloading the VSIX file from the online gallery
- Visit the Visual Studio Gallery – DotNetNuke Project Templates page
- Download the VSIX file via the Download link.
- Double click on the downloaded file to install the templates.
- Install manually by downloading from Codeplex
- Download the VSIX file from Codeplex
- UPDATED - Right Click on the downloaded VSIX and choose Properties
- Click on the UNBLOCK button before proceeding
- 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
- (you should have this done already) Install Visual Studio 2012
- (you should have this done already) Install DotNetNuke Project Templates from the Visual Studio Gallery<!--EndFragment-->
- 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/).
- Run Visual Studio 2012 as an Administrator (right click on the shortcut to do so)
- File –> New Project
- Choose either C# or VB.Net from the Languages section of the new project dialog
- Select the DotNetNuke Folder under your preferred language (C# or Visual Basic)
- Choose either DotNetNuke C# Compiled Module or DotNetNuke VB.Net Compiled Module for your project template
- For the new project creation screen using the following settings
- Name: ModuleName (something unique here, example DNNTaskManager)
- Location: c:\websites\dnndev\desktopmodules\ (this assumes you setup your development environment as instructed in Step 3)
- Solution: Create new solution
- 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)
- Add to source control: Unchecked (I typically get my project running before adding it to source control)
- 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)
- UNBLOCK THE FILE BEFORE PROCEEDING
- 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.
Note: If you are having problems "installing" the module, be sure to close visual studio before uploading the ZIP file into DNN, sometimes Visual Studio will lock files and the installation of your module will fail.