New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Automated DotNetNuke Module Packaging MSBuild

Return to previous page

  • 4/7/2015



Automated DotNetNuke Module Packaging MSBuild

Last updated long time ago



(Enter the content of this article below)


You can easily auto package your modules by making a few changes to the vbproj (or CSPROJ for C#) file for your project. Packaging your module is really just zipping up the correct files. You can do this with MSBuild by using the MS Build Community Tasks extension. Download it and install it from . Once you have that installed its a simple case of editing the vbproj file. To do this in Visual Studio:

  • Right click the project name in Solution Explorer
  • Select Unload Project
  • Right click the greyed out project name in Solution Explorer again
  • Select the Edit option.
    You will now see the MSBuild file for your project.  All of the modules and providers in the DotNetNuke Core project have this modification.  To see this modification you will have to use the source code in the CodePlex source tree as the pacakges distributed in the Source package have this modification removed because it relies on the MSBuild Community tasks being installed and it also causes a security prompt the first time it loads the project.
    The example code below is for the HTML Module.  Since all modules need to be packaged it makes sense to have a generic packaging script and just pass variables to it.  If you look at the HTML Module vbproj file you will a property group section like this:

  • The next line
    <Import Project="..\..\BuildScripts\ModulePackage.Targets" />
    Imports the generic packaging script from the file ModulePackage.Targets.  The next line tells MSBuild to execute the packaging after the build is completed.
    <Target Name="AfterBuild" DependsOnTargets="DebugProject;PackageModule"></Target>

    This line tells MSBuild to execute both the DebugProject and PackageModule tasks, DebugProject is actually in the vbproj file below but the PackageModule task is in the imported build file.  The DebugProject task simply copies files to the root website so you can debug.  The PackageModule task firstly Imports the MSBuild Commumity tasks so we can use the Zip task and the XmlRead task.  This task is only executed when in Release mode.
    Then I use XmlRead to read the version of the module out of the .dnn file. 

    <XmlRead Prefix="n"
    <Output TaskParameter="Value" PropertyName="Version" />

This is then used later to name the package correctly.

Note: If working with a package that contains multiple sub-packages change the xpath to be "dotnetnuke/packages/package1/@version" which will use the FIRST version number for the package.

Next we find the files we need and copy them to a Package folder.  Note that at DNN Corp we use a standard way to arrange our modules so we can use the same script across the modules.
Now that we have all the files in the package folder we use the Zip task to zip all the files up and then create an Install zip file.  Lastly we delete any copied or created folders. 
The nice thing about doing it this way is you don't need to execute any external program to do your build, you simply switch to Release mode and hit build.  The install zip is then created and dropped into the Website/Install/Modules folder ready to install.


Christoc's DotNetNuke Module Development Template
For examples on using MSBuild to package modules check out the 00.00.05 release of the module development templates found at

MS Build for DotNetNuke module development
This extension forge project automates the task of creating DotNetNuke module PA and Source packs using MS Build. This MS Build tasks will generate DNN manifest files (.dnn files for DNN 5.x), it will process and generate version #'s, all file updates, release notes, clean up and much more. In addition to packaging, all .js and .css are minified before putting them in the Install pack, for optimal performance. The original .js and .css files remain untouched. MS Build for DotNetNuke module development
No sections defined
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out