When you build a DNN module using the template or from scratch you probably locate the project under the Desktop modules folder and start developing. Doing this complicates source control and automated building in my experience so I wanted a way to build my modules in a separate folder away from the target host website. Andrew Nurse dropped a snippet of a build script to me that copies the assemblies, pdb files and the rest of the files you need to debug your module on. It copies the files marked as Content in the Build Action.
I also wanted a way to auto package my module ready for the project tracker into zip files for install and source.
So I needed to specify the files I wanted so I used an item group as below:
<ItemGroup>
<ZipSourceFilesInclude="a2z.gif" />
<ZipSourceFilesInclude="App_LocalResources\CategoryEdit.ascx.resx" />
<ZipSourceFilesInclude="App_LocalResources\EditHelp.ascx.resx" />
<ZipSourceFilesInclude="App_LocalResources\Help.ascx.resx" />
<ZipSourceFilesInclude="App_LocalResources\HelpEdit.ascx.resx" />
<ZipSourceFilesInclude="App_LocalResources\NavPane.ascx.resx" />
<ZipSourceFilesInclude="App_LocalResources\Settings.ascx.resx" />
<ZipSourceFilesInclude="App_LocalResources\ViewHelp.ascx.resx" />
Etc
<ZipSourceFilesInclude="CategoryEdit.ascx" />
<ZipSourceFilesInclude="CategoryEdit.ascx.designer.vb" />
<ZipSourceFilesInclude="CategoryEdit.ascx.vb" />
<ZipSourceFiles
<ZipSourceFilesInclude="refresh.gif" />
<ZipSourceFilesInclude="Settings.ascx" />
<ZipSourceFilesInclude="Settings.ascx.designer.vb" />
<ZipSourceFilesInclude="Settings.ascx.vb" />
<ZipSourceFilesInclude="Uninstall.SqlDataProvider" />
<ZipSourceFilesInclude="03.00.02.txt" />
</ItemGroup>
The script below is added to the end of your project file and it copies the files to your host website and then zips them up ready to install.
Enjoy.
<TargetName="AfterBuild"DependsOnTargets="DeployModule">
Target>
<PropertyGroup>
<Major>03Major>
<Minor>00Minor>
<Build>02Build>
PropertyGroup>
<PropertyGroup>
<ProjectName>HelpProjectName>
<ModuleFolder>HelpModuleFolder>
<DNNDirectory>C:\DotNetNuke\Releases\DotNetNuke_04.08.02_InstallDNNDirectory>
<PackageDirectory>C:\DotNetNuke\PackagePackageDirectory>
PropertyGroup>
<TargetName="DeployModule">
<CreateItemInclude="$(MSBuildProjectDirectory)\$(OutputPath)$(AssemblyName).dll">
<OutputTaskParameter="Include"ItemName="ModuleAssemblies" />
CreateItem>
<CreateItemInclude="$(MSBuildProjectDirectory)\$(OutputPath)\*.pdb">
<OutputTaskParameter="Include"ItemName="ModuleDebug" />
CreateItem>
<CopySourceFiles="@(Content)"DestinationFiles="@(Content -> '$(DNNDirectory)\DesktopModules\$(ModuleFolder)\%(Identity)')"SkipUnchangedFiles="true" />
<CopySourceFiles="@(ModuleAssemblies);@(ModuleDebug)"DestinationFolder="$(DNNDirectory)\bin" />
<ZipFiles="@(ZipSourceFiles)"ZipFileName="resources.zip" />
<ZipFiles="@(Content);@(ModuleAssemblies);resources.zip"Flatten="True"ZipFileName="$(ProjectName)_$(Major).$(Minor).$(Build)_Source.zip" />
<ZipFiles="@(Content);@(ModuleAssemblies)"Flatten="True"ZipFileName="$(ProjectName)_$(Major).$(Minor).$(Build)_Install.zip" />
Target>