Build a Compiled DotNetNuke Module using the Visual Studio Starter Kit

The Visual Studio Starter Kit allows you to create a compiled DotNetNuke module that will be more compact, faster, and hide your source code from prying eyes.  The following instructions will get you started and well on your way to creating compiled DotNetNuke Modules.

1. Download the Starter Kit (http://www.dotnetnuke.com/Resources/Downloads.aspx)

2. Open Visual Studio  and create a new project (File -> New Project)

The Add New Project dialog in Visual Studio 2010

From the dialogue follow these steps:

  1. Select Web from the Installed Templates.  I use VB.Net, but they are available in C# as well.
  2. Select DotNetNuke Compile Module from the Project Type list.
  3. Enter your Module Name
  4. Enter the path to your DotNetNuke installation.  Your project will be installed in the existing installation in the DesktopModules folder and the dll will be put in the bin folder.
  5. Click OK

3.  Visual Studio will load up the project in the Solution Explorer and open the Documentation.html in the editor.  You’re not yet ready to install the module so don’t follow the DotNetNuke documentation yet.

4. In the Solution Explorer right click on My Project and select Open.

5. On the Application tab delete the entry in Root Namespace unless this is your only module, or you won’t be sharing code with other modules.  I have a project that spans several modules and I want them all in the same name space.  So, I delete the Root Namespace entry so that I can put in the appropriate namespace from the code behind. (Edit regarding Root Namespace; in C# you don’t have to clear the namespace, but in VB.NET you do).

6. Switch to the Compile tab.  Check the Build output path and make sure its pointing to the right bin folder.  Now click the Advanced Compile Options button at the button of the tab.  On the dialogue make sure the Target framework is correct.  You’ll see the setting at the bottom of the dialogue.  At this point the dialogue will automatically close.

7. Repeat step 4 (open the project properties) then go to step 8

8. Switch to the References tab.  You should see a reference to DotNetNuke.Library version 0.0.0.0.  Remove it.

Project Properties reference tab in Visual Studio 2010

9. Still on the References tab, now click the Add button.  In the Add Reference dialogue switch to the Browse  tab and navigate to the DotNetNuke installation bin folder.  Select the DotNetNuke.dll, DotNetNuke.Web.dll, and the Telerik.Web.UI.dll.  If you don’t have the Telerik.Web.UI.dll then you must not be using those controls and you won’t need the dll.  Click OK.  These references are necessary to get access to the DotNetNuke methods and properties.  Otherwise you’re code behind will be filled with green and blue underlines, missing references, and, oh yeah, it won’t compile.  Kind of defeats the purpose, right?

9a. Intellisense; this step is optional, but if you want Intellisense you’ll want to do this.  Switch to the Web tab. Under Servers select the “Use Local IIS Web server” option.  Change the Project URL to the full URL of your project (eg http://{domain}/DesktopModules/{project folder}).  Check “Override application root URL” and set it to the domain of your DotNetNuke install (eg http://{domain})

10. Save the Project Properties and close it.

11. In the Solution Explorer expand the Components folder and open the {ModuleName}Controller.vb (or .cs) file.  Check the Namespace declaration and you’ll see that it says “YourCompany”.  Change this to your custom namespace identifier and then do the same in all the code behind files.  You will also need to change it in the .ascx files because they’ll be reference the namespace in the control declaration at the top of the page.

12.  At this point you can Build your project and you will see the new dll in your DotNetNuke install bin folder.

13.  Now follow the instructions in the documentation.html to install the module in DotNetNuke.  Once the module is installed you don’t really need the documentation folder, or it’s files.  I usually delete it.

If you want to create a package make sure you put your sql scripts in the 01.00.00.SqlDataProvider file and the follow these instructions on creating an install package.

2 comments for “Build a Compiled DotNetNuke Module using the Visual Studio Starter Kit

  1. January 24, 2014 at 10:20 am

    Hi! Interesting, at last a clear step-by-step guide.

    Nvertheless, I got 100 errors when trying to compile the module :(.
    I am using DNN 5.6.8, so I got that VS StarterKit.
    Point 9a (optional) could not be done.

    I have several modules running, but in source code. I use LINQ2SQL class to all datasources.

    Is there a way compile those already running modules?

    Thanks!

    • January 24, 2014 at 10:21 pm

      Without knowing all of what’s going on there are few things you can try. Compile the modules individually by separating them into their own projects and attaching them to the solution. Reference the necessary DNN dll’s and see if you can build the module.

      Otherwise, what kind of errors are you getting when you build the solution?

Leave a Reply