DNN Blog

Jun 10

Posted by: Chris Hammond
6/10/2010 4:02 PM  RssIcon

UPDATE: The latest release of the templates no longer use NANT, read the updated blog post http://www.dotnetnuke.com/Resources/Blogs/EntryId/2880/New-DotNetNuke-Module-Development-Templates-w-video.aspx

So this is the third and final post in the module development series of blogs I started last week. The first two covered

  1. Configuring your development environment
  2. Customizing and installing a C# module development template

This post is going to tell you how to utilize an open source project called NAnt to package up your modules quickly and easily, so that they can be installed on various DotNetNuke sites. The C# module development template that I released last week comes with a NAnt BUILD script included, so when you create a project using the template (as we do in blog #2) you are ready to use NAnt to package the module, you must get NAnt configure though, so let’s walk through that process.

What is NAnt?

NAnt is an open source .NET build tool that can be found by visiting http://nant.sourceforge.net/ You can do a lot of cool things with NAnt and the C# template linked to above utilizes a NAnt build script to package the module with both a SOURCE and an INSTALL package for deployment.

Installing NAnt

The installation of NAnt is pretty straight forward. Here are the steps for getting it setup for use within my module development template.

  1. Download the BINARY ZIP of the 0.90 release of NAnt from http://nant.sourceforge.net
    image
    testing against the 0.91 Alpha1 release had some failures DO NOT USE 0.91 ALPHA1.
  2. Extract the contents of this ZIP file, this will create a local folder with the same file name
    image
  3. Navigate into the extracted folder until you find a BIN folder, navigate into that BIN folder and copy all of the contents of the folder
    image
  4. Go to your C: drive and create a folder called NANT, within this NANT folder paste what you copied in STEP 3
    image
  5. Now that you have the NAnt files placed we can configure Visual Studio to add NAnt to the external tools menu. To do this you will open up Visual Studio, go to the Tools menu and click on External Tools option, that will bring up a window.
  6. Click on Add and put the information in for nant, here’s a screenshot of what information you should define.
    image 

Using NAnt to automate your module packaging

So now that you have NAnt setup within Visual Studio here comes the easy part. If you have created a project using my template the rest is really easy. You can simply open that project, and do a build within Visual Studio. You must do a build in VS first, because this creates the DLL that Nant is going to use for assembly name and version info. Once you’ve done the manual build you can then choose the Tools menu in Visual Studio and choose the nant menu item.

This will cause NAnt to do a release-compile and package your module! When that happens, you should see something similar to the following in your output window.

image

If you have a “Build Succeeded” message there than you are all set, NAnt has compiled and packaged your module into a folder called package, in the root of your project. You won’t see this folder in Visual Studio, but if you go to the file system, wherever your project is located, you should see the folder.

image

Inside of that folder you should find two ZIP files, one for the INSTALL package and one for the SOURCE package.

image

Installing your newly packages module

So now you have two ZIP files one called INSTALL and one called SOURCE. What do you do with these? Well the install package is just that, a ZIP file that you can use to install your DotNetNuke module onto a DNN web site, it can be any other DNN website, or the website you are currently doing your development on. The source package can also be used to install the module, the difference between the two is that one will install the source code for the module, the other will not.

A few important things to remember about these packages you’ve now created. Because of the way the project is setup, it compiles against whatever version of DNN you have in your development environment, you will not be able to install the module on an older version of DNN without first recompiling the module, though you will be able to install it on a newer version of DotNetNuke.  Another thing to remember, the project template that I released last week is for a basic module but that module doesn’t have any functionality built into it. There are three ASCX files, some language resource files, CSS, and a few other random bits included, but none of those bits actually do anything until you add some functionality.

That’s where standard ASP.NET development comes into play. You can add labels, buttons, and various other controls to the ASCX files to start making them actually perform a function. In future blog posts I will demonstrate some simple modules that have been developed using this template to get you a better understanding of more aspects of DotNetNuke Module Development.

DotNetNuke Training from DotNetNuke Corporation

For now, if you are interested in learning more check out the DotNetNuke Module Development webinar that I am teaching next week as part of our DotNetNuke Training. The webinar is 4 hours a day (8am PST – 12pm PST), Tuesday through Friday (June 15-18, 2010). If you can’t get signed up for next week the course will be offered again in August!

37 comment(s) so far...


Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Great series on module development Chris. It's always good to read about new tools and methods for module development and packaging. I've never used NAnt but will give it shot for my next module dev project. Thanks.

By Vincent Malanga on   6/16/2010 8:43 AM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Hmmm... I've always packaged manually myself, but have been meaning to try this out. So, I will end up finding out the answers to the three questions below myself, but I think some might be wondering:

How does NAnt know how to package the modules into source vs. install?

What packaging style does NAnt use?

Do we need to do anything different in our manifest files to account for NAnt?

By Will Strohl on   6/24/2010 4:32 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

1. The nant file included with my template tells NANT to do a SOURCE and an INSTALL package inside the script.

2. Nant packages however you to tell it, the scripts I use package as much as possible into resources.zip and leave the least amount of files in the main DNN Zip as possible for the module to install. Which in turn keeps the .DNN file itself as small as possible.

3. That depends on what you use for a Nant script, my module template that I released is all configured and ready to go.

By Chris Hammond on   6/24/2010 4:34 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Great Blog series Chris.. Being new to DNN, let alone being brand new to Module creation I'm really looking forward to your next Blog, can't wait to see this in action. I've already installed it on my test box, as you mentioned it doesn't do anything, but pretty cool that its there. In the meantime any suggested reading, Internet or Purchased books, you would recommend to someone just starting out, maybe one of the C# for dummies books or something?

Thanks,
Bob

By Bob McKinley on   6/29/2010 12:46 AM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Bob, I think you'll find Mitchel Seller's book is the best option for Module Development right now. I'm also going to do another post here soon to start "using" the module template to do some real things. Hopefully early this week

By Chris Hammond on   6/29/2010 12:46 AM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Another great post! Thanks. I like the idea of what nant's suppose to do -- but I'm getting an error running it because I'm on a 64 bit system. Due to line #45 in the build script (${sys.env.windir}) --- my result is sys.env.CommonProgramFiles(x86) which is invalid.

I got it to work by hard coding the filepath to my msbuild.exe and setting failonerror="false" -- but as I'm not very familiar w/ Nant -- I wanted to know if you knew of a fix - or if I'm OK anyways.

Thanks!

By Andrew Walker on   7/6/2010 6:18 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Andrew, i'm running 64bit as well and haven't run into the issue specifically.

By Chris Hammond on   6/29/2010 3:48 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Hi Chris,

I followed your guide in order to setup NANT with Visual Studio 2008 on Windows 7 32 bit but I cannot build the package because I get the following error:

C:\inetpub\wwwroot\dev\DesktopModules\Test\Test.build(153,6):
Zip file 'C:\inetpub\wwwroot\dev\DesktopModules\Test\ResourceZip\Resources.zip' could not be created.
1 is not a supported code page.
Parameter name: codepage

What could the problem be? I used your template and modified the description etc.

By Simon on   7/6/2010 7:31 AM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

@Simon, what version of NANT are you using?

By Chris Hammond on   7/5/2010 11:43 AM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

I downloaded the 0.90 binary zip as you wrote in the article.

By Simon on   7/6/2010 7:27 AM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Hi Chris,
This is a very nice tutorial. Using NANT makes things less complicated. Everything worked perfect on my first try.
I have ASP.NET experience but I am new to DNN. I will be attending your module development webinar this July.

thank you.

By Antonio Lopez on   7/6/2010 6:08 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

A better version of the .build is available here : www.dotnetnuke-fr.org/Accueil/Article/tabid/67/Art/28/language/fr-FR/Automatiser-le-packaging-avec-NAnt.aspx

By Sebastien Fichot on   9/8/2010 12:31 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Hi. I was just wondering if you have tested against the 0.91 Alpha 2 version?

By Darnell Greer on   9/20/2010 9:19 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

I haven't tested against any other releases of 0.91, I still recommend 0.90 as stated in the blog post

By Chris Hammond on   9/20/2010 9:19 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

I am working on a Vista machine 64 bit. I am getting failed builds from nant. The issue seems to be that nant doesn't like the file path. I read above about hard coding a path to msbuild, but I don't know how to do that. Have you caught wind of any solutions for such problems?

init:

[property] Target framework changed to "Microsoft .NET Framework 2.0".
[sysinfo] Setting system information properties under sys.*
[sysinfo] Property could not be created for environment variable 'CommonProgramFiles(x86)' : Property name 'sys.env.CommonProgramFiles(x86)' is invalid.
[sysinfo] Property could not be created for environment variable 'ProgramFiles(x86)' : Property name 'sys.env.ProgramFiles(x86)' is invalid.

There is more like: Command line error BC2026, but I have a feeling that if it could just read the path those would go away.

By Darnell Greer on   10/29/2010 2:13 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Darnell, are you using the template I blogged about for your project? What version of NANT are you using?

By Chris Hammond on   10/29/2010 2:19 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Darnell I ended up fixing the VB issue in a recent project by changing the Target Framework to 2.0, then changing it back to 3.5, for some reason that seems to fix the NANT script with VB.

By Chris Hammond on   10/30/2010 12:07 AM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Tip on changing the target framework in VB, go to Project Properties, COMPILE tab, then ADVANCED

By Chris Hammond on   10/30/2010 12:08 AM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

I am not very experienced with this so I am missing something. I changed the framework from 3.5 to 2.0 and I get the same error message about the file path being invalid. I know you are busy man, but do you possibly have the steps you took when you changed to 2.0 available to post? Did you have to manually make some file changes so that it would build in VS? Could the fact that I am using VS2010 be a factor?

By Darnell Greer on   10/30/2010 12:46 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Darnell, I ended up switching to 2.0 then back to 3.5. After the conference next week I'll try to put some more time into this, unfortunately I can't until I'm back from Vegas

By Chris Hammond on   10/30/2010 12:47 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

I am not very experienced with this so I am missing something. I changed the framework from 3.5 to 2.0 and I get the same error message about the file path being invalid. I know you are busy man, but do you possibly have the steps you took when you changed to 2.0 available to post? Did you have to manually make some file changes so that it would build in VS? Could the fact that I am using VS2010 be a factor?

By Darnell Greer on   11/8/2010 12:46 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Have A Great Vegas Chris!!

By Darnell Greer on   11/8/2010 12:46 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Darnell, I'll have a new Template out sometime next week that fixes the VB issues

By Chris Hammond on   10/30/2010 3:32 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Thanks for the heads up Chris. I will check back.

By Darnell Greer on   11/8/2010 12:46 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Hi Chris. I am just getting back here. Are you saying that this issue is only VB related?

By Darnell Greer on   11/8/2010 12:46 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Darnell, I do believe the C# template was working fine, though the VB one had issues. I've made some progress on the templates, and am actually pulling the NANT scripts out of the next release, going with MSBuild scripts, I'll have a blog together later this week on how to use the new templates and the automated packaging.

By Chris Hammond on   11/8/2010 12:47 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Ok Chris. Thanks! I guess I should start learning something about C# just the same.

By Darnell Greer on   11/22/2010 11:19 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

I also encountered the same issue like Darnell and my computer is win7 64bit. I tried to hard code like that: but it failed too. Any helps?

Thanks a lot
Baldwin

By Baldwin on   11/22/2010 11:19 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Hi Chris. I was just wondering if you have had any luck on the build scripts for the vb template.

By Darnell Greer on   11/23/2010 4:11 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Hey Chris,
I have followed your instructions here precisely however I keep getting the same error over and over again when I try to use NANT.

/*************************
BUILD FAILED

Could not find a '*.build' file in '\ModuleName'

For more information regarding the cause of the build failure, run the build again in debug mode.

Try 'nant -help' for more information
/*****************************************/

I am using the C# template and Visual Studio 2010.

Please advise.

Thanks

By dave barel on   5/18/2011 3:45 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Dave, you are likely using the NEWER template which uses MSBuild instead of NANT

By Chris Hammond on   5/18/2011 3:46 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Thank you Chris, I appreciate your time.

I have the latest MSBuild installed and I changed the build mode to 'release' and built the project. However, I couldn't find any folder named 'Package' anywhere. The build was successful but I was only to create dll as can be seen here:

/********************************/
------ Build started: Project: TheKickLogger, Configuration: Debug Any CPU ------
TheKickLogger -> C:\inetpub\wwwroot\DNNDev5620\DesktopModules\bin\TheKickLogger.dll
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped *****************************/

Am I missing something? Because I was looking everywhere for the package folder.

Thanks again.

By dave barel on   5/22/2011 8:38 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Dave, You don't appear to have things configured properly. You've got the module build into the wrong folder, which tells me that you likely have your module one folder too deep in the file system.

Your module should be in

/desktopmodules/ModuleName

not in /desktopmodules/ModuleName/ModuleName

Chris

By Chris Hammond on   5/22/2011 8:39 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

I'm having the same problem. I'm using C# and getting the "Could not find a '*.build' file in '\ModuleName'"

Has there been any resolution?

By Matthew Humora on   10/11/2011 2:29 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Matthew H, the templates no longer use NANT, please read the updated blog post linked above, and all the instructions on the Codeplex pages

By Chris Hammond on   10/11/2011 2:29 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Hai sir,

after the build am getting this below error.
BUILD FAILED

Could not find a '*.build' file in '\ModuleName'

For more information regarding the cause of the build failure, run the build again in debug mode.

Try 'nant -help' for more information

cant able to solve the error.... ple help me to clear... thanks a lot in advance,,,,, thanks....

By Arun on   1/25/2012 12:13 PM
Gravatar

Re: Configuring NAnt to package your DotNetNuke Modules

Arun please see the previous comments, and the blog post above that says the NANT scripts are no longer used

By Chris Hammond on   1/25/2012 12:14 PM
Attend A Webinar
Free Demo Site
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me
Have Someone Contact Me
Charlotte DoDNN

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

Exact Target Exec Alert
r2integrated
Telerik JustCode Free

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates the DotNetNuke Store where users purchase third party apps for the platform.