Welcome to weblogs.com.pk Sign in | Join | Help

Introducing MyMSBuildTasks.SqlDataSourceTask

ASP.NET v2’s SqlDataSource is great; but for small apps or while doing prototyping / inception. It starts creating problem in later stages of mid to big level projects. In such cases; we might want that with each release; all SqlDataSources being used are documented so that you can track which database objects are being used. Its a tedious job, especially when your development team size is small and you dont have dedicated resources for "configuration management".

Thankfully we have ASP(X) Parser (I introduced ASP Pareser earlier) and MSBuild; and we can now create a task that does this job for us. Today I and my son had plan to visit zoo; but news is that there is some repair work going on; so I availed this time and created one such task.

You can download the MyMSBuildTasks (source and binaries) from here. To use it:

  1. Create MyMSBuildTasks folder under %Program Files%\MSBuild and place the dlls (ASP.dll and MyMSBuildTasks.dll) and MyMSBuildTasks.Targets file there.

  2. In your web application project (wap) (Only WAP based project will work) import the targets file and define the task (I am lazy, havnt defined XSD so you will not have any intellisence in VS.NET IDE); task has two required properties that you need to set which are self explainatory.

  3. Build your wap and you will have an XML file with all the required info.

The source is simple and crude; you are free to modify and re-use it. Beware of some post-build events and references in the project/solution.

I wish that someone can do the following with this

  • Add ObjectDataSource task on similar lines; extending the DataSet accordingly; XML file being written is basically a typed dataset.
  • Using LINQ over DataSet implement some desktop app to query generated XML / DataSet; with pre-configured queries like All Connection Strings, All SPROCs in given connection string etc
  • Create a CodeSmith template that generate a data access layer harvesting the XML file; so that SqlDataSources can be replaced with ObjectDataSource straight-forwardly


Published Saturday, November 4, 2006 2:25 PM by khurram


No Comments

New Comments to this post are disabled