DotNetNuke Modules – Automating the PA
Last week we showed how to create a basic Program Assembly (PA). You’ll remember that a lot of the process was manual. And if you make a process manual, it is always open to error.
But there is a better way. By using the Microsoft Web Deployment Project along with the MSBuild Community Task, you can completely automate all but creating the DNN file.
You will need:
Download and install those now.
The rest of this post will assume that you’ve already created the module that you want to build the Program Assembly for.
- You will want to create a deployment project by selecting the DNN Project in the solution explorer and then selecting the “Build” > “Add Web Deployment Project…” from the menu. Once you select the menu option, a dialog will appear prompting you for the name of the deployment project and the location you want it to be in. I find it easiest to place the project under inetpub/wwwroot like any other web project, but it really will not matter where you place it.
- Once the web deployment project has been created, right click the project and select “Property Pages” from the menu. We need to change a few of the defaults the deployment project has set up.
- When the properties dialog displays, select “Output Assemblies” from the tree on the left-hand side of the dialog. Then select the radio button that says, “Merge each individual folder output to its own assembly.” You’ll probably also want to set the file and assembly version here, so check that box and enter the values.
- Next, select “Deployment” from the tree and check the “Remove the App_Folder from output location” check box.
- Press “OK” to exit.
- To get the rest of the magic to happen we need to drop into the msbuild source. To do this, right click on the deployment project and select, “Open Project File” from the menu. This should bring up an XML file in a text editor. Once you have it open, you should see an import statement around line 47 (near the bottom):
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WebDeployment\v9.0\Microsoft.WebDeployment.targets" />
You’ll want to insert another line below it and move the two lines up before the first <ItemGroup> element:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WebDeployment\v9.0\Microsoft.WebDeployment.targets" /> <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
This will allow this project to use the build extensions we installed earlier.
- You should also see several “PropertyGroup” sections followed by an empty ItemGroup section. Within this item group section we will want to exclude files from being part of the build. For example, there are VB files that are part of the DNN install that we don’t want to be part of the build, so we need to exclude them. Since I work in Csharp, I can tell it to just exclude all of the VB files, but if you work in VB, you will need to exclude them explicitly. You’ll also want to exclude the following:
- Anything under the admin directory
- Anything under the portals directory
- Any ASPX or ASCX files in the root directory of the website project
- Anything under the components directory
- Anything under the config directory
- Anything under the images directory
- Anything under the install directory
- Anything under the js directory
- Anything under the providers directory
- Anything under any module directories that are not the module you are building the deployment project, and ultimately a PA, for.
- My ItemGroup section looks like this:
<ItemGroup> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\admin\**\*.*" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\Portals\**\*.*" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.vb" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\*.as?x" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\Components\**\*.*" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\Config\**\*.*" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\images\**\*.*" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\install\**\*.*" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\js\**\*.*" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\providers\**\*.*" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\DesktopModules\HTML\**\*.*" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\DesktopModules\AuthenticationServices\**\*.*" /> <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\DesktopModules\SplitTester\**\*.*" /> </ItemGroup>
If you are not familiar with msBuild, the \**\*.* means “Any files in the directory or in any of its subdirectories.”
- If you build the deployment project now, you should end up with files in the directory you specified when you created the deployment project. As a note, you may want to set the deployment project up so that it only builds in release mode. Otherwise, you’ll have to go through this extra build step while you are developing, which can significantly slow you down.
- There are two directories in the deployment project that we are interested in. The bin directory should have a dll for all the files in the App_Code/ModuleName directory and a DLL for all of the files in the DesktopModules/ModuleName directory. If you are using the multiple project method to create DLLs for the BaseProvider and SQLProvider you’ll also have a DLL for the base provider project and a DLL for the SQL provider project. There should also be ASCX and RESX files that are part of our module under the DesktopModules directory. If we set up everything correctly, there should only be one directory there.
- Next, we need to copy all of the files that we want to be part of our installation into one installation directory. To do this, you’ll need to uncomment out the after build section:
<Target Name="AfterBuild">
And place some copy commands in it. Here’s just one line of many such lines from one of my files:
<Exec Command="copy .\release\bin\App_SubCode_dmbcllcStore.dll .\installation\App_SubCode_dmbcllcStore.dll" />
<Exec Command="del /Q installation\*.*" />
<CreateItem Include="installation\*.*"> <Output ItemName="ZipFiles" TaskParameter="Include" /> </CreateItem>
And then telling the build process to make a zip file out of them:
<Zip ZipFileName="dmbcllcStore.zip" WorkingDirectory="installation" Files="@(ZipFiles)" />
I’m sure if someone wanted to get really clever, they could actually use this process to create the DNN file for them as well so that there is only one file that has to be modified when a new file is added to the PA. For the amount of time it would save, I haven’t found that effort worth the time. For the most part, the number of files in a module remain rather static.
Other post in DotNetNuke - Module Development
- Creating DotNetNuke Modules - May 20th, 2008
- Creating DNN Modules - The Tools - May 22nd, 2008
- DotNetNuke Modules - Foundational Concepts - May 26th, 2008
- DotNetNuke Modules - Install DNN into VS 2008 - May 27th, 2008
- DotNetNuke Modules - Creating Base Modules - May 28th, 2008
- DotNetNuke Modules - Registering Your Module - May 29th, 2008
- DotNetNuke Modules - Where Stuff Shows Up - June 3rd, 2008
- DotNetNuke Modules - Benefits of Architecture - June 4th, 2008
- DotNetNuke Modules - Anatomy of the View - June 9th, 2008
- DotNetNuke Modules - Adding Actions - June 11th, 2008
- DotNetNuke Modules - DNN Controls - Label - June 18th, 2008
- DotNetNuke - Internationalization - June 25th, 2008
- DotNetNuke Modules - Internationalization (part 2) - June 30th, 2008
- DotNetNuke Modules - Labels w/ no Help - July 9th, 2008
- DotNetNuke Modules - LinkButtons - July 14th, 2008
- DotNetNuke Modules - Collapsible Panels - July 16th, 2008
- DotNetNuke - The Data Layer - Installing CodeSmith - July 22nd, 2008
- DotNetNuke - Modules - Creating The Tables - July 24th, 2008
- DotNetNuke - Modules - Creating Stored Procs - July 29th, 2008
- DotNetNuke - Modules - Portal Specific Modules - July 31st, 2008
- DotNetNuke Modules - Data Access Layer - August 5th, 2008
- DotNetNuke Modules - Data Access Layer - August 7th, 2008
- DotNetNuke - Data Access Layer Alternative - August 12th, 2008
- DotNetNuke - Modules - Linking within the module - August 14th, 2008
- DotNetNuke - Make Your Module Searchable - August 19th, 2008
- DotNetNuke Modules - Making Content Portable - August 25th, 2008
- DotNetNuke Modules - Exceptions the DNN Way - September 2nd, 2008
- DotNetNuke Modules - PortalModuleBase - September 4th, 2008
- DotNetNuke Modules - Inter Module Communication - September 9th, 2008
- DotNetNuke Modules - Finding The Page a Module is On - September 15th, 2008
- DotNetNuke Modules - Caching - September 17th, 2008
- DotNetNuke Modules - Module Settings - September 22nd, 2008
- DotNetNuke Modules - Retrieving Settings - September 24th, 2008
- DotNetNuke Modules - Advanced Architecture - October 20th, 2008
- DotNetNuke Modules - Creating the PA - October 30th, 2008
- DotNetNuke Modules - Automating the PA - November 5th, 2008
- DotNetNuke - FileUploadControl Danger! - February 26th, 2009
- DotNetNuke SecurityException AspnetHostingPermission - October 14th, 2009
- Changing an Existing DNN Module - March 4th, 2010
Other Related Items:
Don't Mess With Me... Programmer on Women's Cotton T-Shirt (in 22 colors)100% preshrunk heavyweight cotton; double-needle stitching throughout; seamless rib at neck; shoulder-to-shoulder tape; heather grey is 90% cotton, 10% polyester; fashion cut; 5/8" rib collar; fitted tapered sleeve.
Active Server Pages (ASP)/Visual Basic (VB).NET - Instructor-based Video Training BundleInteractive Instructor-Based Active Server Pages (ASP)/Visual Basic (VB).NET Bundle Video Training Course on DVD-ROM. Computer Based Training (CBT) a... Read More >
MCTS Self-Paced Training Kit (Exam 70-562): Microsoft .NET Framework 3.5-ASP.NET Application Development: Microsoft(r) .Net Framework 3.5 ASP.Net Application Development (Pro - Certification)Ace your preparation for the skills measured by MCTS Exam 70-562âand on the job. Work at your own pace through a series of lessons and reviews... Read More >









