tags:

views:

603

answers:

2

Hello guys, I am just looking for some option in dotnetnuke or some utility or some installer module of dnn which could make installer (.zip package) of my dynamic desktop module.

at the moment when i try to create module package through Host->Module Definition... It only creates package of those files which does exist in that Module folder but i want it should also include relevant DLL and Database Script, Please guide me how can I include dependent/relavent dll and script files.

Thanks, Report Post

+5  A: 

I suggest that NAnt be used to automate the packaging process for each module. It takes a little bit of set up and configuration, but if you package modules frequently, over time it saves an incredible amount of effort. It also ensures that you are consistently building the package in the same way every time you package your module.

Steps:

1) Download and extract NAnt to a location on your computer. I recommend using the 0.86 beta 1 build of NAnt.

2) Incorporate NAnt into Visual Studio as an "External Tool"

Bill Simser instructs:

  1. Create a new External Tool by going to Tools | External Tools
  2. Click Add to add a new tool
  3. Give it a title of "NAnt"
  4. Browse to the location of the NAnt.exe file wherever you have it downloaded to Set the initial directory to $(SolutionDir) (where your .build file resides)
  5. Click on "Use Output Window"
  6. Click OK In the external tools menu

3) Incorporate a build script into your solution

As an example, here is the build file for the Tell A Friend module that I've created. The full source to the module is also available.

You'll want to verify that all of the initial properties are valid for your module. For example, you'll definitely want to change the "project.name", "solution.file", and "project.dll" properties. But you may also need to change other properties as well (The references directory is a good candidate, as you may not have structured the module's dependent assemblies in the same way on the file system).

<?xml version="1.0" encoding="utf-8" ?>
<project xmlns="http://nant.sf.net/release/0.86-beta1/nant.xsd" name="Engage: Tell A Friend" basedir="." default="package">
  <property name="build" value="true" overwrite="false"/>
  <property name="bin.directory" value="..\..\bin" overwrite="false"/>
  <property name="project.config" value="release"/>
  <property name="project.name" value="TellAFriend"/>
  <property name="solution.file" value="Engage${project.name}.sln"/>
  <property name="references.directory" value="References"/>
  <property name="project.dll" value="${bin.directory}\Engage${project.name}.dll"/>

  <patternset id="content.fileset">
    <include name="**/*.ascx" />
    <include name="**/*.aspx" />
    <include name="**/*.asmx" />
    <include name="**/*.resx" />
    <include name="**/*.html" />
    <include name="**/*.htm" />
    <include name="**/*.css" />
    <include name="**/*.jpg" />
    <include name="**/*.gif" />
    <include name="**/*.png" />
    <include name="**/*.pdf" />
    <include name="**/*.xml"/>
    <include name="**/*.xsd"/>
    <exclude name="Licenses/EULA-*.htm"/>
    <exclude name="ReleaseNotes_*.htm"/>
    <exclude name="??.??.??.txt" />
    <exclude name="_ReSharper.*/**"/>
  </patternset>
  <patternset id="source.fileset">
    <include name="**/*.js"/>
    <include name="**/*.cs"/>
    <include name="**/*.vb"/>
    <include name="**/*.sln"/>
    <include name="**/*.csproj"/>
    <include name="**/*.vbproj"/>
    <include name="**/*.build"/>
    <include name="**/*.dnn"/>
    <include name="**/*.docx"/>
  </patternset>

  <target name="build" description="Builds the solution" if="${build}">
    <exec program="${environment::get-variable('windir')}\Microsoft.NET\Framework\v3.5\msbuild.exe" failonerror="true">
      <arg value="${solution.file}" />
      <arg value="/p:Configuration=${project.config}" />
      <arg value="/p:Platform=&quot;Any CPU&quot;" />
    </exec>
  </target>
  <target name="get-version" depends="build" description="Sets the project.version property to the first three numbers from the version of the main assembly for this module">
    <property name="version" value="${assemblyname::get-version(assembly::get-name(assembly::load-from-file(project.dll)))}" />
    <property name="project.version" value="${string::substring(version,0,string::last-index-of(version,'.'))}" />
  </target>
  <target name="package" depends="get-version" description="Creates packages for this module, one for each three licenses and version of DNN (4 and 5)">
    <property name="package.directory" value="package"/>
    <property name="package.name" value="Resources.zip"/>
    <property name="package.license" value="Free"/>
    <property name="includeSource" value="false"/>

    <call target="setup-package-files"/>
    <call target="create-resources-zip"/>
    <call target="create-packages"/>

    <property name="includeSource" value="true"/>
    <call target="add-sources-to-resource-zip"/>
    <call target="create-packages"/>

    <delete file="${package.directory}\${package.name}" failonerror="false"/>
    <delete dir="${package.directory}\temp" failonerror="false"/>

    <call target="project-specific-tasks"/>
  </target>
  <target name="create-resources-zip" description="Creates the Resources.zip file for content (Install package) files">
    <mkdir dir="${package.directory}" failonerror="false"/>
    <mkdir dir="${package.directory}/temp" failonerror="false" />
    <mkdir dir="${package.directory}/temp/resources" failonerror="false" />
    <copy todir="${package.directory}/temp/resources" flatten="false">
      <fileset>
        <patternset refid="content.fileset"/>
        <exclude name="obj/**"/>
        <exclude name="${package.directory}/**"/>
      </fileset>
    </copy>

    <zip zipfile="${package.directory}/temp/package/${package.name}">
      <fileset basedir="${package.directory}/temp/resources">
        <include name="**/*"/>
      </fileset>
    </zip>
  </target>
  <target name="add-sources-to-resource-zip" description="Adds the files for the Source package to the Resources.zip file">
    <copy todir="${package.directory}/temp/resources" flatten="false">
      <fileset>
        <patternset refid="source.fileset"/>
        <exclude name="obj/**"/>
        <exclude name="${package.directory}/**"/>
      </fileset>
    </copy>

    <zip zipfile="${package.directory}/temp/package/${package.name}">
      <fileset basedir="${package.directory}/temp/resources">
        <include name="**/*"/>
      </fileset>
    </zip>
  </target>
  <target name="setup-package-files" description="Copies common package files to the temp/package directory, and sets version-dependent attributes in the DNN 5 manifest file">
    <property name="releaseNotes.file" value="ReleaseNotes_${project.version}.htm"/>
    <property name="license.file" value="EULA-${package.license}.htm"/>
    <mkdir dir="${package.directory}/temp/package" failonerror="false"/>
    <copy todir="${package.directory}/temp/package" flatten="true">
      <fileset>
        <include name="${releaseNotes.file}"/>
        <include name="??.??.??.txt" />
        <include name="ReadMe.txt" />
        <include name="**/*.SqlDataProvider"/>
        <include name="**/*.4.dnn"/>
        <include name="**/*.5.dnn"/>
        <include name="Licenses/${license.file}"/>
      </fileset>
    </copy>
    <copy todir="${package.directory}/temp/package/bin" flatten="true">
      <fileset>
        <include name="${project.dll}"/>
        <include name="${references.directory}/*.dll"/>
        <exclude name="${references.directory}/DotNetNuke.dll"/>
        <exclude name="${references.directory}/DotNetNuke.WebUtility.dll"/>
        <exclude name="${references.directory}/Microsoft.ApplicationBlocks.Data.dll"/>
      </fileset>
    </copy>

    <attrib readonly="false">
      <fileset basedir="${package.directory}/temp/package">
        <include name="**"/>
      </fileset>
    </attrib>

    <xmlpoke file="${package.directory}/temp/package/Engage${project.name}.5.dnn" value="${license.file}" xpath="dotnetnuke/packages/package/license/@src"/>
    <xmlpoke file="${package.directory}/temp/package/Engage${project.name}.5.dnn" value="${releaseNotes.file}" xpath="dotnetnuke/packages/package/releaseNotes/@src"/>
    <xmlpoke file="${package.directory}/temp/package/Engage${project.name}.5.dnn" value="${project.version}" xpath="dotnetnuke/packages/package/@version"/>
    <xmlpoke file="${package.directory}/temp/package/Engage${project.name}.5.dnn" value="${project.version}" xpath="dotnetnuke/packages/package/components/component[@type='Script']/scripts/script[@type='UnInstall']/version"/>
    <xmlpoke file="${package.directory}/temp/package/Engage${project.name}.5.dnn" value="${project.version}" xpath="dotnetnuke/packages/package/components/component[@type='Assembly']/assemblies/assembly[version='REPLACED BY NANT']/version"/>
    <!--<xmlpoke file="${package.directory}/temp/package/Engage${project.name}.4.dnn" value="${project.version}" xpath="dotnetnuke/folders/folder/version"/>-->
  </target>
  <target name="create-packages" description="For the given license and type, creates packages for DNN 4 and DNN 5">
    <property name="dnn.version" value="4"/>
    <call target="zip-package"/>

    <property name="dnn.version" value="5"/>
    <call target="zip-package"/>
  </target>
  <target name="zip-package" description="Zips up the files in the temp/package directory, getting the correct manifest file and using the correct naming convention">
    <property name="package.type" value="Install"/>
    <if test="${includeSource}">
      <property name="package.type" value="Source"/>
    </if>
    <zip zipfile="${package.directory}/${project.name}_${package.license}_${project.version}_${package.type}_${dnn.version}.zip">
      <fileset basedir="${package.directory}/temp/package">
        <include name="**/*"/>
        <exclude name="**/*.4.dnn" if="${dnn.version=='5'}"/>
        <exclude name="**/*.5.dnn" if="${dnn.version=='4'}"/>
      </fileset>
    </zip>
  </target>
  <target name="combine-enterprise" description="Combines the Install and Source enterprise packages into one .zip file">
    <zip zipfile="${package.directory}/${project.name}_${package.license}_${project.version}_${dnn.version}.zip">
      <fileset basedir="${package.directory}">
        <include name="${project.name}_${package.license}_${project.version}_Install_${dnn.version}.zip"/>
        <include name="${project.name}_${package.license}_${project.version}_Source_${dnn.version}.zip"/>
      </fileset>
    </zip>

    <delete file="${package.directory}/${project.name}_${package.license}_${project.version}_Install_${dnn.version}.zip" failonerror="false"/>
    <delete file="${package.directory}/${project.name}_${package.license}_${project.version}_Source_${dnn.version}.zip" failonerror="false"/>
  </target>
  <target name="project-specific-tasks" description="Place tasks specific to the current project in this task">
  </target>
</project>

4) Run the external tool which executes the build script, and verify your package.

Other resources:

Ian Robinson
A: 

A simpler way (ie without having to learn Nant) would be to use the visual studio pre-build and post-build events (see the project properties for your module project).

You can also call a batch file to do the work, as described here: Module Package Builds Revisited.

Hope this helps, Pete.

Pete Morgan