Back when I was working on version 1.1 of the RsWebParts I setup a build script for my project which I think is pretty useful. It automates the process of creating DWP files and packaging the project using the WP Packager tool.
The first step in automating this process was to create a console application that I called the DwpGenerator. I did this because I grew tired of forgetting to change version numbers or trying to look up the public key token of an assembly. The DwpGenerator is a simple application that takes a web part assembly and generates a dwp file for each web part it finds in the assembly. It uses .Net Attributes to gather other information such as title and description. These are set in the web part assembly. For example, here is the RsExplorer web part's class declaration:
[DefaultProperty("ServerUrl"), ToolboxData("<{0}:RsExplorer runat=server>"), XmlRoot(Namespace="Bml.RsWebParts"), Description("Explore a Reporting Services Server."), Title("RS Explorer"), PartImage("_WPR_/ReportExplorer.gif")] public class RsExplorer : RsBasePart, IRowProvider, IPostBackEventHandler, IDesignTimeHtmlProvider { .... }
The DwpGenerator picks up the title and description from these attributes. The generator doesn't look for any specific class of attributes, so you can create your own. It only looks at the name of the attribute to determine if it should use it. So for the above web part the dwp that gets generated looks like:
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"> <Title>RS Explorer< SPAN>Title> <Description>Explore a Reporting Services Server.< SPAN>Description> <Assembly>Bml.RsWebParts, Version=1.2.0.0,Culture=neutral, PublicKeyToken=4fafef280eaa1b9c< SPAN>Assembly> <TypeName>Bml.RsWebParts.RsExplorer< SPAN>TypeName> <PartImageLarge>_WPR_/ReportExplorer.gif< SPAN>PartImageLarge> < SPAN>WebPart>
The next part of the automation involves the wppackager tool. This tool is great for generating an installer program for web parts. The only drawback is that you need to copy every file into the same folder for the tool to work. However, it is pretty easy to automate copying files. So here is my post build event command line process for the Bml.RsWebParts:
c:\temp\DwpGenerator.exe "$(TargetPath)" "$(ProjectDir)"copy "$(ProjectDir)\manifest.xml" "$(TargetDir)"copy "$(ProjectDir)\*.dwp" "$(TargetDir)"copy "$(ProjectDir)\images\*.gif" "$(TargetDir)"copy "$(ProjectDir)\xsl\*.xsl" "$(TargetDir)"copy "$(ProjectDir)\scripts\*.js" "$(TargetDir)""c:\program files\wppackager\wppackager.exe" "$(ProjectDir)\wppackager.xml"del "$(TargetDir)\*.xml"del "$(TargetDir)\*.gif"del "$(TargetDir)\*.dwp"del "$(TargetDir)\*.xsl"del "$(TargetDir)\*.js"
That is all there is to it. Now I can make changes to my project and when I build it everything is updated.