Click here to Skip to main content
15,867,834 members
Articles / Database Development / SQL Server
Article

NUKEleus - A DotNetNuke Installation Program

Rate me:
Please Sign up or sign in to vote.
4.57/5 (15 votes)
10 Mar 20056 min read 108.8K   247   50   22
An installation program for the popular DotNetNuke ASP.NET portal.

Sample Image - NUKEleus.gif

Introduction

I'm a DotNetNuke(DNN) evangelist. Many a late night has been spent coding new modules, building skins, and not-so-patiently waiting for the next version to arrive. If I have any complaints about DNN, it is about the fact that DNN has a constant "under construction" sign on its door. It is never really quite finished, because as soon as one release comes out, some newer, cooler technology comes down the road, and off goes the core team to integrate it and bring it to the grateful minions. So can I really complain at all?

One downside to that constant development cycle is that sometimes the "spit and polish" falls to the wayside. It is a product made by developers for developers, and so we just dig in and get our hands dirty when needed. But it would be nice if some things were just a little easier for the novice.

A noticeably lacking feature of DNN is an installer. In order to install the portal, you have to unzip the files, set permissions, create a virtual directory, create a database, and edit configuration files. Not a problem for most visitors of CodeProject. But that might be a handful for your novice programmer or anyone not intimately familiar with ASP.NET, IIS or MS SQL.

I didn't happen to have an extra few hundred dollars laying around in order to purchase a copy of InstallShield or Wise and create one of those "pretty" installers, so I rolled my own. NUKEleus is the end result. I hope you enjoy it.

Features

NUKEleus is a typical wizard in every sense. The interface looks nice and was easy to create due in large part to the Wizard Framework from DivElements. NUKEleus will walk you through the following steps, handling all the messy work for you.

  • Allows you to install any version of DotNetNuke.
  • Creates an install folder (you can choose where to install DNN).
  • Unzips the files.
  • Gives appropriate folder permissions to the machine's ASP.NET account.
  • Creates a virtual directory (you can choose the VDir name).
  • Creates a blank database in SQL Server (you can choose the database name).
  • Edits the Web.Config file with your custom information.
  • Edits the DotNetNuke.sln and DotNetNuke.vbproj.webinfo files so that you can open the solution.

In addition, NUKEleus is open source, and under the standard GNU license, so it can grow and gather support from the community as needed.

Stumbling Blocks

Writing this installer was a real learning process for me. I had no idea how to perform several of the necessary actions, such as creating virtual directories and assigning NTFS permissions. And I'm still not 100% happy with the way things have been implemented. But the program is working, and that is the first step. I'm hoping that the community will jump in with more code to make this an even more polished product than it already is.

Assigning NTFS Folder Permissions

Probably, the hardest part of getting started with this problem was figuring out how to Google on it. "Give <machinename>\ASPNET rights to a folder" was not getting me any results. Several hours and several Advil into my search, I started to come across some rather interesting acronyms, such as Security Descriptors (SDs), Access Control Lists (ACLs) and Access Control Entries (ACEs). All of these have to do with setting security permissions - not only on folders, but on almost anything. The bad news was that .NET does not seem to have a library built into it that handles these (at least not that I'm aware of). Most of the source code examples available were in C++, which didn't help me in a VB.NET environment. Other examples were in older code, such as this example of high level routines from MSDN. After much trial and error, I just wasn't getting the results I wanted, so I fell back on a command line utility that I located to complete the job. Once I get this article published, I intend to look into this problem a little further.

Creating a Virtual Directory

Creating virtual directories programmatically was a little easier, not only because I was able to locate some code for it, but because .NET supported it to begin with. It's not an intuitive process however. I don't think a quick peek into the MSDN library would make it clear. The key to creating VDir's is the System.DirectoryServices.DirectoryEntry. Although the code below is rather long winded, the nutshell version is that you need to create a Directory entry, assign the necessary properties to it, and then commit the changes. In that regard, it is somewhat like adding a record to a database. Anyway, here is the code:

VB.NET
 Private Sub CreateVDir(ByVal WebSite As String, ByVal VDirName As String, _
             ByVal Path As String, ByVal RootDir As Boolean)
     Dim IISSchema As System.DirectoryServices.DirectoryEntry
     Dim IISAdmin As System.DirectoryServices.DirectoryEntry
     Dim VDir As System.DirectoryServices.DirectoryEntry
     Dim IISUnderNT As Boolean
     IISSchema = New System.DirectoryServices.DirectoryEntry("IIS://" & _
                                               WebSite & "/Schema/AppIsolated")
     If IISSchema.Properties("Syntax").Value.ToString.ToUpper() = "BOOLEAN" _
     Then
         IISUnderNT = True
     Else
         IISUnderNT = False
         IISSchema.Dispose()
         IISAdmin = New System.DirectoryServices.DirectoryEntry("IIS://" & _
                                                   WebSite & "/W3SVC/1/Root")
         ' If the virtual directory already exists then delete it
         For Each v As DirectoryEntry In IISAdmin.Children
             If v.Name = VDirName Then
                 'Delete the specified virtual directory if it already exists
                 Try
                     IISAdmin.Invoke("Delete", _
                         New String() {v.SchemaClassName, VDirName})
                     IISAdmin.CommitChanges()
                 Catch ex As Exception
                     MsgBox("Error deleting existing VDir:" & ex.Message, _
                             MsgBoxStyle.Critical, "Error Deleting VDir")
                 End Try
            End If
        Next
        If Not RootDir Then
            VDir = IISAdmin.Children.Add(VDirName, "IIsWebVirtualDir")
        Else
            VDir = IISAdmin
        End If
        VDir.Properties("AccessRead")(0) = True
        VDir.Properties("AccessExecute")(0) = True
        VDir.Properties("AccessWrite")(0) = False
        VDir.Properties("AccessScript")(0) = True
        VDir.Properties("AuthNTLM")(0) = True
        VDir.Properties("EnableDefaultDoc")(0) = True
        VDir.Properties("EnableDirBrowsing")(0) = False
        VDir.Properties("DefaultDoc")(0) = _
                                       "default.htm,default.aspx,default.asp"
        VDir.Properties("Path")(0) = Path
        VDir.Properties("AppFriendlyName")(0) = VDirName
        If Not IISUnderNT Then
            VDir.Properties("AspEnableParentPaths")(0) = True
        End If
        VDir.CommitChanges()
        If IISUnderNT Then
            VDir.Invoke("AppCreate", False)
        Else
            VDir.Invoke("AppCreate", 1)
        End If
    End If
    pageVirtualDirectory.AllowMoveNext = True
End Sub

Unzipping a ZIP File

Here again, I'm rather surprised that such a common requirement is not handled by internal .NET libraries, but - it isn't. Fortunately, the community jumped rather quickly on this one, and produced a wonderful library called SharpZipLib. Unzipping using this library is rather straightforward, and there are examples on the web of how to do this. What I'll make you note however is the RaiseEvent call at the bottom of the code. Since unzipping a large file (all the DNN files are large) can take a while, I thought it is best to run this operation in a separate thread. This allows the end user to pause or cancel the unzipping operation as needed. I'm still pretty new to the whole multi-threading paradigm, but its about time VB.NET gained this ability.

VB.NET
Private Sub Unzip()
    Dim strmZipInputStream As ZipInputStream = _
                           New ZipInputStream(File.OpenRead(bfFileName.Text))
    Dim objEntry As ZipEntry
    Dim count As Integer = 1
    objEntry = strmZipInputStream.GetNextEntry()
    While IsNothing(objEntry) = False
        Dim nSize As Integer = 2048
        Dim abyData(2048) As Byte
        Dim directoryName As String = bfFolder.Text & _
                                        Path.GetDirectoryName(objEntry.Name)
        Dim fileName As String = Path.GetFileName(objEntry.Name)
        lblFile.Text = "Extracting: " & fileName
        ProgressBar1.Value = count
        Directory.CreateDirectory(directoryName)
        If fileName <> "" Then
            Dim StreamWriter As FileStream = _
                        File.Create(directoryName & "\"    & fileName)
            While True
                nSize = strmZipInputStream.Read(abyData, 0, abyData.Length)
                If nSize > 0 Then
                    StreamWriter.Write(abyData, 0, nSize)
                Else
                    Exit While
                End If
            End While
            StreamWriter.Close()
        End If
        count += 1
        objEntry = strmZipInputStream.GetNextEntry()
    End While
    strmZipInputStream.Close()
    RaiseEvent ThreadComplete()
End Sub

A Blatant Plug For Self

I love writing wizards and tools. I quickly realized that one thing I do over and over is create special fields to locate files and folders. To that end, I created the BrowseControls. They allow you to drop controls right on your WinForm and never think again about all the coding it takes just to pick a file or folder from a hard drive.

Musings and Warnings

NUKEleus is a relatively untested product at the moment. Use it with care. It is intended for new installations of DotNetNuke only. It can be used for upgrades, but doing so will overwrite your Web.Config and recreate your virtual directories, etc. You should always backup your files and database before attempting any kind of DNN upgrade anyway.

In order to keep this software open and growing, I have also added it to SourceForge.

Wrap Up

I hope you like this program, and know you'll love DotNetNuke if you get to know it. If you have any comments, suggestions or fixes, please make your voice heard.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Systems Engineer Virtual RadioLogic
United States United States
Todd Davis has been working in web and application development for several years, using Silverlight, ASP.NET, VB.NET, C#, C++ and Javascript, as well as a great deal of work with SQL server and IIS.

He currently works for Virtual Radiologic in Eden Prairie, MN, however he is better known for his varied work in the open source community, especially the DotNetNuke project for which he provided several world-renowned training videos and modules. A huge advocate of open source and open knowledge sharing, everything on his website (www.SeaburyDesign.com) is always offered for free.

Whenever he is not actively coding at his laptop (a rarity to be sure), he can be found woodworking, walking with his wife and kids, or motoring along the back roads of MN on his Harley Davidson Fatboy.

Comments and Discussions

 
GeneralSet NTFS permission [modified] Pin
morejobs14-Mar-07 17:39
morejobs14-Mar-07 17:39 
GeneralRe: Set NTFS permission Pin
morejobs14-Mar-07 17:58
morejobs14-Mar-07 17:58 
.NET 2.0 now have built in classes to set NTFS permissions

http://msdn2.microsoft.com/en-us/library/system.security.accesscontrol.directorysecurity.aspx
QuestionFor Which Version(s)? Pin
sdfsdeew ee14-Sep-06 1:08
sdfsdeew ee14-Sep-06 1:08 
AnswerRe: For Which Version(s)? Pin
Todd Davis14-Sep-06 3:05
Todd Davis14-Sep-06 3:05 
GeneralCant get it to work with Don't work with 4.x Pin
anderslundsgard6-Jul-06 2:32
anderslundsgard6-Jul-06 2:32 
GeneralFailed to Set Permissions On Folder Pin
nkhamm18-Jun-06 12:30
nkhamm18-Jun-06 12:30 
GeneralWeb.config error Pin
itinko17-Apr-06 5:02
itinko17-Apr-06 5:02 
Generalpermission Pin
amit__816-Mar-06 0:35
amit__816-Mar-06 0:35 
GeneralInstaller Error Pin
IPITsystems7-Feb-06 23:11
IPITsystems7-Feb-06 23:11 
GeneralRe: Installer Error Pin
Todd Davis8-Feb-06 2:46
Todd Davis8-Feb-06 2:46 
GeneralRe: Installer Error Pin
Artem Smirnov11-Mar-06 9:03
professionalArtem Smirnov11-Mar-06 9:03 
GeneralShared hosting Pin
John Shutt27-Oct-05 5:24
John Shutt27-Oct-05 5:24 
GeneralQuick Thank you ! Pin
staffel9524-Sep-05 17:10
staffel9524-Sep-05 17:10 
GeneralExcellent Work Pin
RonLF18-Sep-05 18:00
RonLF18-Sep-05 18:00 
QuestionHow to create virtual directory from ASP.NET Application? Pin
Benedict Alphonse15-May-05 18:24
Benedict Alphonse15-May-05 18:24 
QuestionIs &quot;EnableDefaultDoc&quot; Option working ..? Pin
Anonymous25-Apr-05 10:45
Anonymous25-Apr-05 10:45 
GeneralGood work! Pin
sveinmagne29-Mar-05 2:32
sveinmagne29-Mar-05 2:32 
GeneralExcellent work! - Thank you very much Pin
Anonymous12-Jun-05 8:52
Anonymous12-Jun-05 8:52 
QuestionUnattended? Pin
dnnstuff10-Mar-05 9:21
sussdnnstuff10-Mar-05 9:21 
AnswerRe: Unattended? Pin
Todd Davis10-Mar-05 9:28
Todd Davis10-Mar-05 9:28 
GeneralRe: Unattended? Pin
dnnstuff11-Mar-05 5:11
sussdnnstuff11-Mar-05 5:11 
GeneralRe: Unattended? Pin
Todd Davis11-Mar-05 5:18
Todd Davis11-Mar-05 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.