Fervent Coder

Coding Towards Utopia...by Rob Reynolds
posts - 278 , comments - 431 , trackbacks - 0

My Links

News


Rob Reynolds

Subscribe to Fervent Coder RSS
Subscribe to Fervent Coder by Email

About Me

I manage several open source projects. Need...
   ...package management for Windows?
   ...automated builds?
   ...database change management (migrations)?
   ...your application to check email?
   ...a monitoring utility?

I also write for



Like what you are reading? Want to buy me a cup of coffee?
PayPal - The safer, easier way to pay online!

Archives

Post Categories

Sites

Running Tarantino With MSBuild

To set up Tarantino to run you follow the instructions from my last couple of posts.  Once you've done that, you set up a file to run the project.

This is how you set up your folder structure.

 Tarantino_FolderStructure

Under db are two folders, Create and Update. In MSBuild, all of the required files to run, plus my MSBuild file (tarantino.proj).

Here is how you set up a batch file to call MSBuild to run your database updates. This file is named dbdeploy.bat.

@echo on SET DIR=%~d0%~p0% C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe "%DIR%msbuild\tarantino.proj" /t:default

pause

I included another file called dbdeploy.Create.bat to show how I override a property.

@echo on

SET DbAction=Create

SET DIR=%~d0%~p0%

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe "%DIR%msbuild\tarantino.proj" /t:default /p:DbAction=%DbAction%

pause

Here's the contents of the tarantino.proj file

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="Tarantino.Targets" />
  
  <PropertyGroup>
    <DbAction>Update</DbAction>
    <!-- Create, Update, Drop, Rebuild -->
    <DbScriptsDirectory>..\db</DbScriptsDirectory>
    <DbInstance>.</DbInstance>
    <DbName>test</DbName>
  </PropertyGroup>

  <Target Name="Default" >
    <!--
    <ManageSqlDatabaseTask
        ActionString="Update"
        ScriptsDirectory="..\db"
        Server="."
        Database="test"
        IntegratedAuthentication="true"
        Username=""
        Password=""
        />
    -->

    <ManageSqlDatabaseTask
        ActionString="$(DbAction)"
        ScriptsDirectory="$(DbScriptsDirectory)"
        Server="$(DbInstance)"
        Database="$(DbName)"
        IntegratedAuthentication="true"
        />
  </Target>

</Project>

And the contents of the tarantino.targets file.

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask 
    AssemblyFile="Tarantino.DatabaseManager.Tasks.dll" 
    TaskName="Tarantino.DatabaseManager.Tasks.ManageSqlDatabaseTask" 
   />
</Project>

Very small and to the point. It gives me the ability to make the call to ManageSqlDatabaseTask above.

Here's a picture of the run. Isn't it pretty? :D

Tarantino_MSBuild

But what is reading versus trying? Download the code below and try this out for yourself!

Update: I caught a small annoyance that occurs if you call msbuild and the path to the .proj has spaces in it (like C:\Documents and Settings\). When you download, surround the path in quotes (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe "%DIR%msbuild\tarantino.proj" /t:default).

Update (29 MAR 2009): I fixed the download to have that path in it.

 

kick it on DotNetKicks.com

Print | posted on Wednesday, March 25, 2009 6:46 AM | Filed Under [ Code ]

Feedback

Comments are closed.
Comments have been closed on this topic.

Powered by: