本文转自: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.
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.
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.
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.
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.
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.
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.
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.
Once you’ve installed the templates, you can setup a project based on the templates. To do so you should follow the steps below
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.
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.