Module development Template for DNN 7.0

本文转自:http://www.chrishammond.com/blog/itemid/2616/using-the-new-module-development-templates-for-dot.aspx 在此,特别感谢Chris的DNN开发模板

原文更新日期为:Thursday, September 19, 2013 4:20 PM

 

With the release of DotNetNuke 7.0 (and now the more recent 7.0.2), it was time to update my module development project templates. If you have worked with my module development templates before, here are the major changes for this release. If you haven’t worked with them before please read this whole blog post as I discuss how to get up and running with the templates.

What’s New

This section will cover some of the “new” features of this template release. If you’re familiar with my previous releases this will hopefully get you up to speed on what is new. If you are new to the whole process it will help you understand a few of the features in the templates.

New DAL2 Templates

The biggest change for the project is that I have added two new DAL2 templates to the project, one for C# and one for VB.Net. These new templates are called DotNetNuke 7 C# DAL2 Compiled Module and DotNetNuke 7 VB.Net DAL2 Compiled Module respectively. As you can see by the name, they use the new DAL2 data access layer available in DotNetNuke 7. Basically you can create a project from one of these two templates and you will have a functioning module (after you build and install of course, see below for those steps) that allows you to create/edit/delete an Item. The Item in the module is pretty simple, with just a few properties, and an ItemController that provides the interaction with the DAL2 and the database. These two templates are a change from previous releases of my template project where the projects you create from the template are empty modules that you have to populate for functionality. With the DAL2 templates it only made sense to provide some out of the box functionality to get you going. You can obviously change the names of the object (Item) and objectcontroller (ItemController) and add additional properties as necessary, be sure to update the SQL script though for any new properties, it can be found in the providers/dataprovider/sqldataprovider folder. For more information on DAL2 check out some of Charles Nurse’s posts here, here, here and here.

New URL (dnndev.me)

Module development Template for DNN 7.0_第1张图片For some people getting the development environment setup has been the most difficult part of the use of these templates. The old templates used a URL that required you to configure your HOSTS file to spoof a DNS entry, with the new templates you don’t have to do that. The new templates use DNNDEV.ME as the website name/domain name. The public DNS for dnndev.me actually points to 127.0.0.1, so no matter where you try to access that domain from it will always resolve to your loopback address, perfect for people who have trouble modifying the DNS via the HOSTS file. If you already have your environment setup at DNNDEV you can simply add another host binding in IIS to that same website with the name DNNDEV.ME. If you are new to development, see more information below about configuring your environment.

Support for Visual Studio 2012 Express for Web

One of the requests for the last few releases of the templates has been support for the Visual Studio Express sku. After quite a bit of testing I figured out that the Visual Studio Gallery will not allow my templates to work for both the paid and free SKUs for Visual Studio 2012. I have however come up with a work around for this. If you download the VSIX file from Codeplex you can install the templates in a way that they should work with Express. If you download the template from the Visual Studio Gallery however they won’t. If you don’t need the Express support you can still grab the templates from the gallery which should actually prompt you to upgrade now that a new release is out, if you had the previous release installed.

How to use the Templates

Getting up and running with the templates is actually fairly easy, but you should follow some very specific steps, not following the steps makes it hard for anyone else to be able to assist you as you can configure things any number of ways that might cause problems.

Configuring your Development Environment

This is one of the most important steps of the process, the templates are configured to run in a website under the URL http://dnndev.me/ There are a couple of resources for setting up your environment, including this Wiki page, but the easiest approach would likely be to watch this 4 part video series I created for DNN7, as it walks you through setting up a website at http://dnndev.me. The important thing for the new release of the templates is that you must have DNN 7.0.2 (or a newer release as they come) running at dnndev.me, unless of course you modify the templates yourself, but that is outside of the scope of this blog post.

Installing the 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 in Visual Studio 2012   
    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. UPDATED - Right Click on the downloaded VSIX and choose Properties
    3. Click on the UNBLOCK button before proceeding
    4. Double click on the downloaded file to install the templates.

Creating your Visual Studio Project

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. Install Visual Studio 2012 (you should have this done already)
  2. Install the project templates as instructed above
  3. Setup your DotNetNuke Development Environment as instructed above
  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, DotNetNuke VB.Net Compiled Module, DotNetNuke 7 C# DAL2 Compiled Module or DotNetNuke 7 VB.Net DAL2 Compiled Module for your project template.
  9. Module development Template for DNN 7.0_第2张图片For the new project creation screen using the following settings   
    1. Name: ModuleName (something unique here, example MyModule)
    2. Location: c:\websites\dnndev.me\desktopmodules\ (this assumes you setup your development environment as instructed in Step 3)
    3. Solution: Create new solution (this option might not be displayed, that is okay)
    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
  10. In some cases Visual Studio will turn the DesktopModules folder in to a Virtual Directory, this will cause problems with your DNNDEV.me environment, load IIS Manager (start>run>INETMGR) and remove the Virtual Directory if it appears as one there.   

Installing your Module in Development

After you create your project in Visual Studio 2012 the module will exist in the c:\websites\dnndev.me\desktopmodules\MyModule folder, but it is not technically installed and registered with DotNetNuke. To do that you need to perform the follow steps.

  1. Build your project in DEBUG mode.
  2. Change to Release mode and build again.
  3. Login to your development website in a browser, using a HOST/SuperUser account.
  4. Navigate to the Host/Extensions page
  5. Choose the Install Extension Wizard option
  6. Click Choose File
  7. Browse to your c:\websites\dnndev.me\desktopmodules\MyModule\Install\ and choose either the INSTALL or SOURCE package to upload.
  8. Go through the steps for the installation wizard (if the module fails to install, try closing Visual Studio first, then install the module)
  9. Place your module on a page (I typically create a new page for each module in my development environment for testing purposes).

Installing your Module in Production

To install your module in production you will follow the same steps as installing it in your development environment, except you will almost NEVER use the SOURCE package of a module in production, it just isn’t necessary.

你可能感兴趣的:(cms,Module,template,development,dnn7,ASPDOTNET)