65.9K
CodeProject is changing. Read more.
Home

Custom MSBuild Tasks: Automated Report and DB Deployment

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.94/5 (7 votes)

Jun 22, 2006

viewsIcon

76601

downloadIcon

461

Automate your Reporting Services report deployment and scripting and database tasks by using these custom MSBuild tasks.

Sample Image - CustomMSBuildTask_RS.jpg

Introduction

This library wraps the RS.exe tool and the OSQL.exe tool in custom MSBuild tasks, so you can automate Reporting Services Report and Scripting deployment, and SQL Server object scripting into an MSBuild project. The Osql custom task is based on the sample by Joey Benninghove, found on his blog.

You can create custom tasks for MSBuild by extending/deriving from the Task base class or by implementing the ITask interface. Feel free to use the source code, and please send me any comments or improvements.

Usage

To consume one of these tasks, just create an XML-based MSBuild project file like the following, and run it using the MSBuild.exe command:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="DeployReportCatalog" 
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile=
  "C:\Projects\Silvaware.MSBuild.Tasks\bin\Debug\Silvaware.MSBuild.Tasks.dll" 
  TaskName="Rs" />

 <PropertyGroup>
    <SqlToolsFolder>C:\program files\microsoft sql server\90\Tools\Binn
    </SqlToolsFolder>  
    <RsTool>$(SqlToolsFolder)\rs.exe</RsTool>
    <TargetReportServer>http://localhost/ReportServer</TargetReportServer>
</PropertyGroup>

 <ItemGroup>
     <TargetItems Include="**\*.rss" />
 </ItemGroup>

 <Target Name="DeployReportCatalog">   
     <Rs RsPath="$(RsTool)" InputFile="@(TargetItems)" 
         ServerURL="$(TargetReportServer)" WaitForExit="true" />
 </Target>

</Project>

The example above executes all Reporting Services script files (.rss) found in the subdirectories of this project recursively. These .rss files could contain VB.NET code to deploy report RDLs, datasources, create folders, roles, assign security, etc.

All the arguments/parameters that the RS.exe and the OSQL.exe tool can take from the command line have been exposed in the custom task as public properties, such as the RsPath and the InputFile properties used in the above example.

Happy MSBuild-ing!