Recently I have been building more DotNetNuke modules than in previous months and I found myself spending a fair amount of time building installation packages to test my modules on my secondary DotNetNuke portal.  After spending more time than I care to admit manually copying these files over, I created a simple command line batch program and added it as a post build event in my project.  This way every time I re-compile my module Visual Studio will automatically create my installation package.  Below I will provide a bit of direction as well as providing a link to download my sample .bat file.

Overview

In the end for MOST DotNetNuke module projects the file structures are very similar, in the root of the project you have your .aspx files, in an App_LocalResources folder you have your .resx files and in the obj\release folder you have your .dll(s).  Well using this overall structure I created this simple batch process to copy the files as needed.  This example is using the standard file structures for a compiled module using C# and the templates from BiteTheBullet.co.uk.  Other solution structures might require additional steps.

The Batch File

When I created the batch file I used a very simple approach by creating the installation package using 6 distinct steps.  First I copy over the .resx files, then the .SqlDataProvider files, then .ascx files, then any .aspx files, and lastly the .dnn and .dll files.  You will need to simply modify the two path sections for each XCOPY statements.  The first is the copy from path, this would be the full path to your project, the second is the path to the location that you would like the installation package to be created.  Be sure that for all 6 statements that the second path is the same, as DNN installation packages are all created in one folder.

Sample make.bat file

Using this batch file, you simply need to zip the files to create your installation package. Below I will show you how to have Visual Studio automatically execute the batch script on each build of your module.

Visual Studio Integration

The process of setting Visual Studio to execute the .bat file after each build is as simple as adding a post build event to the Build Events section of your project properties.  Right click on your project and select "properties", you will see the below window.  Switch to the Build Events view.

VS Properties

In the post-build command line section you simply put the FULL file path to the .bat file that you created based on my example from above.  Now, each time you build your solution the files will be copied successfully.

Conclusion/Disclaimer/Words of Caution

This article is designed to be a quick overview of a method to create semi-automatic DNN module builds.  You MUST sanity check all XCOPY statements in your created .bat file to ensure that you will not accidentally overwrite or modify any files that you did not intend on modifying.  XCOPY does NOT notify you about overwriting it simply does it expecting that you knew it would!

This is a great way to help automate your build processes.  If you need assistance setting this up please use my support forum that is available on this site!