<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>MSBUILD</title>
        <link>http://blogs.imeta.co.uk/mnotaras/category/118.aspx</link>
        <description>MSBUILD</description>
        <language>en-GB</language>
        <copyright>Mark Notaras</copyright>
        <generator>Subtext Version 2.1.1.1</generator>
        <item>
            <title>MSBUILD Property Assertions Using the Error Task</title>
            <link>http://blogs.imeta.co.uk/mnotaras/archive/2009/04/24/686.aspx</link>
            <description> I defined an ItemGroup for all files and folders under a directory passed as the ‘TargetDir’ property:
&lt;p class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;ExistingFiles&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Include&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;span style="COLOR: blue"&gt;$(TargetDir)\**\*.*&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;o:p /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;If the ‘TargetDir’ property has an empty value the item collection contains &lt;strong style="mso-bidi-font-weight: normal"&gt;all&lt;/strong&gt; files and folders of the root directory.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;Although the behavior makes sense, it highlights the importance of checking certain properties have been set. This would have been very nasty if the item collection was used in conjunction with the Delete task for example!&lt;/p&gt;
&lt;p class="MsoNormal"&gt;The Error task can be used to stop the build based on a certain condition and can be used to check that a property has been set:&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Error&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Condition&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;span style="COLOR: blue"&gt;'$(TargetDir)'==''&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Text&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;Target dir property not set, ensure properties file could be located&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;o:p /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-ansi-language: EN-GB; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;font face="Arial" size="2"&gt;The complete task reference can be found here &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/7z253716.aspx"&gt;http://msdn.microsoft.com/en-us/library/7z253716.aspx&lt;/a&gt;.&lt;/span&gt;&lt;img src="http://blogs.imeta.co.uk/mnotaras/aggbug/686.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mark Notaras</dc:creator>
            <guid>http://blogs.imeta.co.uk/mnotaras/archive/2009/04/24/686.aspx</guid>
            <pubDate>Fri, 24 Apr 2009 10:30:17 GMT</pubDate>
            <wfw:comment>http://blogs.imeta.co.uk/mnotaras/comments/686.aspx</wfw:comment>
            <comments>http://blogs.imeta.co.uk/mnotaras/archive/2009/04/24/686.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.imeta.co.uk/mnotaras/comments/commentRss/686.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.imeta.co.uk/mnotaras/services/trackbacks/686.aspx</trackback:ping>
        </item>
        <item>
            <title>MSBUILD Automated Deployments of Databases using the MS SDC Task Library</title>
            <link>http://blogs.imeta.co.uk/mnotaras/archive/2009/04/24/685.aspx</link>
            <description>&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;strong style="mso-bidi-font-weight: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Intro&lt;o:p /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;Following on from my previous post on &lt;a target="_blank" href="http://http://blogs.imeta.co.uk/mnotaras/archive/2009/01/14/563.aspx"&gt;automated deployment of websites&lt;/a&gt;, another common task is database deployment. The freely available Microsoft SDC Task Library contains a library of custom MSBUILD tasks to facilitate this process.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;This post describes a generic script I wrote which uses these tasks to create/update a SQL Server database as part of an automated deployment. A subsequent post will look at how Microsoft SDC can be used to apply permissions to the database.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;strong style="mso-bidi-font-weight: normal"&gt;Into&lt;/strong&gt; &lt;strong style="mso-bidi-font-weight: normal"&gt;Practice&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;Download the latest version of the SDC task library from &lt;a href="http://codeplex.com/sdctasks"&gt;http://codeplex.com/sdctasks&lt;/a&gt;, and add it to your solution so it’s available to the build process.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;Add the following ‘using’ to your build script to import the Micrsoft.Sdc.Tasks.Sql.Execute task. This task is used to run SQL commands and scripts:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;UsingTask&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;AssemblyFile&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;span style="COLOR: blue"&gt;Microsoft.Sdc.Tasks.dll&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;TaskName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;Microsoft.Sdc.Tasks.Sql.Execute&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;o:p /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;The Execute command accepts the following main arguments: &lt;/font&gt;&lt;/p&gt;
&lt;ul style="MARGIN-TOP: 0cm" type="disc"&gt;
    &lt;li class="MsoNormal" style="MARGIN: 0cm 0cm 10pt; mso-list: l0 level1 lfo1"&gt;&lt;font face="Calibri" size="3"&gt;&lt;strong&gt;ServerName&lt;/strong&gt;: SQL Server instance name to connect to&lt;/font&gt; &lt;/li&gt;
    &lt;li class="MsoNormal" style="MARGIN: 0cm 0cm 10pt; mso-list: l0 level1 lfo1"&gt;&lt;font face="Calibri" size="3"&gt;&lt;strong&gt;DatabaseName&lt;/strong&gt;: Database to run SQL scripts/commands against&lt;/font&gt; &lt;/li&gt;
    &lt;li class="MsoNormal" style="MARGIN: 0cm 0cm 10pt; mso-list: l0 level1 lfo1"&gt;&lt;font face="Calibri" size="3"&gt;&lt;strong&gt;Sql&lt;/strong&gt;: Optional SQL command to run against the database&lt;/font&gt; &lt;/li&gt;
    &lt;li class="MsoNormal" style="MARGIN: 0cm 0cm 10pt; mso-list: l0 level1 lfo1"&gt;&lt;font face="Calibri" size="3"&gt;&lt;strong&gt;Path&lt;/strong&gt;: Optional path to a SQL script to run against the database&lt;/font&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;For more information on this and the other tasks in the SDC toolkit, refer to the Microsoft.Sdc.Tasks reference compiled help file which comes packaged with the assemblies.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;The script allows a database to be created or updated based on a passed ‘DeploymentType’ property, the first task uses a Condition to evaluate if a ‘Create’ deployment is being performed and if true runs a SQL command to create the database. &lt;font face="Calibri" size="3"&gt;The SQL command is executed substituting the passed ‘DatabaseName’ property:&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;Execute&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;ServerName&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;"&lt;span style="COLOR: blue"&gt;$(ServerName)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;DatabaseName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;master&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Sql&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;CREATE DATABASE $(DatabaseName)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;CommandTimeout&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(Timeout)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Condition&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;'$(DeploymentType)'=='Create'&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;o:p /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;You could use the same method to drop any existing instances of the database on the server.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;As well as executing SQL statements the execute command supports running a SQL Script from the file system by specifying the Path argument. I used this in conjunction with MSBUILD batching to run the create/update scripts from a particular folder against the database:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;Execute&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;ServerName&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;"&lt;span style="COLOR: blue"&gt;$(ServerName)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;DatabaseName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(DatabaseName)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Path&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;%(Scripts.Identity)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;CommandTimeout&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(Timeout)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Condition&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;'$(DeploymentType)'=='Create'&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;o:p /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;Notice the use of the %(Scripts.Identity) notation which causes MSBUILD to run the Execute task for each of files in the Scripts item group. The Scripts item group includes all the *.SQL scripts under the given ‘ScriptBase’ folder and its sub folders and is defined as follows:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;ItemGroup&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;Scripts&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;Include&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;"&lt;span style="COLOR: blue"&gt;$(ScriptBase)\**\*.sql&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;o:p /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;ItemGroup&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;Folders are supported in order to provide a simple mechanism to define the order that the scripts should be run against the database:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;img height="91" alt="" width="160" src="/images/blogs_imeta_co_uk/mnotaras/folder struct.jpg" /&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;&lt;v:stroke joinstyle="miter" /&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0" /&gt;&lt;v:f eqn="sum @0 1 0" /&gt;&lt;v:f eqn="sum 0 0 @1" /&gt;&lt;v:f eqn="prod @2 1 2" /&gt;&lt;v:f eqn="prod @3 21600 pixelWidth" /&gt;&lt;v:f eqn="prod @3 21600 pixelHeight" /&gt;&lt;v:f eqn="sum @0 0 1" /&gt;&lt;v:f eqn="prod @6 1 2" /&gt;&lt;v:f eqn="prod @7 21600 pixelWidth" /&gt;&lt;v:f eqn="sum @8 21600 0" /&gt;&lt;v:f eqn="prod @7 21600 pixelHeight" /&gt;&lt;v:f eqn="sum @10 21600 0" /&gt;&lt;/v:formulas&gt;&lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" /&gt;&lt;o:lock v:ext="edit" aspectratio="t" /&gt;&lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1025" style="WIDTH: 120pt; HEIGHT: 68.25pt" type="#_x0000_t75"&gt;&lt;v:imagedata src="file:///C:\Users\MARKNO~1\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png" o:title="" /&gt;&lt;/v:shape&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;More information on MSBUILD batching can be found at &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms171473(VS.80).aspx"&gt;&lt;font face="Calibri" color="#800080" size="3"&gt;http://msdn.microsoft.com/en-us/library/ms171473(VS.80).aspx&lt;/font&gt;&lt;/a&gt;&lt;font face="Calibri" size="3"&gt;, and batching on metadata and conditions at &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms171474(VS.80).aspx"&gt;&lt;font face="Calibri" color="#800080" size="3"&gt;http://msdn.microsoft.com/en-us/library/ms171474(VS.80).aspx&lt;/font&gt;&lt;/a&gt;&lt;font face="Calibri" size="3"&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;The same method is used to execute the update scripts:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;Execute&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;ServerName&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;"&lt;span style="COLOR: blue"&gt;$(ServerName)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;DatabaseName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(DatabaseName)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Path&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;%(UpdateScripts.Identity)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;CommandTimeout&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(Timeout)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Condition&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;'$(DeploymentType)'=='Update'&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-fareast-language: EN-GB; mso-no-proof: yes"&gt;&lt;font face="Calibri" size="3"&gt;Here is the &lt;a target="_blank" href="/images/blogs_imeta_co_uk/mnotaras/DeployDatabase.txt"&gt;complete script&lt;/a&gt;.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.imeta.co.uk/mnotaras/aggbug/685.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mark Notaras</dc:creator>
            <guid>http://blogs.imeta.co.uk/mnotaras/archive/2009/04/24/685.aspx</guid>
            <pubDate>Fri, 24 Apr 2009 09:24:47 GMT</pubDate>
            <wfw:comment>http://blogs.imeta.co.uk/mnotaras/comments/685.aspx</wfw:comment>
            <comments>http://blogs.imeta.co.uk/mnotaras/archive/2009/04/24/685.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.imeta.co.uk/mnotaras/comments/commentRss/685.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.imeta.co.uk/mnotaras/services/trackbacks/685.aspx</trackback:ping>
        </item>
        <item>
            <title>MSBUILD Automated Deployments of Web Applications using the MS SDC Task Library</title>
            <link>http://blogs.imeta.co.uk/mnotaras/archive/2009/01/14/563.aspx</link>
            <description>&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;strong style="mso-bidi-font-weight: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Intro&lt;o:p /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;A common scenario of a team build solution is deploying the application on a nightly basis to provide the test team with an up-to-date deployment to test against. Such early visibility will help maintain the quality of the product over the development lifecycle.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;The types of projects we work on commonly have a web application component, be it a front end or in the form of WebServices. Using the Microsoft SDC Task Library extensions for MSBUILD, web applications can be automatically deployed and configured under IIS 6.0/7.0 relatively easily.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;strong style="mso-bidi-font-weight: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Into Practice&lt;o:p /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;The SDC Task Library is freely available at &lt;a href="http://codeplex.com/sdctasks"&gt;http://codeplex.com/sdctasks&lt;/a&gt;, the library isn’t limited to deploying websites, tasks include the functionality to execute SQL scripts, run installers, edit xml files and much more.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;Download the library and add the Microsoft.Sdc.Tasks.dll assembly somewhere under your solution in source control so it is available during the build process.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;To reference a task in the library from you MSBUILD script add a UsingTask. Set the AssemblyFile to the location of the assembly relative to the script and set the TaskName to the name of the Sdc task you want to use including the namespace.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;UsingTask&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;AssemblyFile&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;"&lt;span style="COLOR: blue"&gt;Microsoft.Sdc.Tasks.dll&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;TaskName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;Microsoft.Sdc.Tasks.Web.WebSite.Create&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;Call the Task from within a Target in the usual way, so for example to create a new Website on a server somewhere:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;Create&lt;o:p /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;MachineName&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;"&lt;span style="COLOR: blue"&gt;$(MachineName)&lt;/span&gt;"&lt;o:p /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;Description&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;"&lt;span style="COLOR: blue"&gt;$(WebsiteName)&lt;/span&gt;"&lt;o:p /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;Path&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;"&lt;span style="COLOR: blue"&gt;$(Path)&lt;/span&gt;"&lt;o:p /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;&lt;span style="mso-spacerun: yes"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;Port&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes; mso-fareast-language: EN-GB"&gt;"&lt;span style="COLOR: blue"&gt;$(Port)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;o:p /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;font face="Calibri" size="3"&gt;Each of the Tasks are well documented in the compiled help file, which is included in the download.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt"&gt;&lt;strong style="mso-bidi-font-weight: normal"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Troubleshooting&lt;/font&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;
    &lt;div&gt;&lt;font face="Calibri" size="3"&gt;The user that your Team Build Service runs as on the build machine must be an administrator on the machine that is hosting the web application&lt;/font&gt;&lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;div&gt;&lt;font face="Calibri" size="3"&gt;If you are deploying to IIS 7.0 you need to have the IIS 6.0 Management Compatibility services installed&lt;/font&gt;&lt;/div&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 11pt; FONT-FAMILY: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-ansi-language: EN-GB; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'"&gt;IIS including the compatibility services must be installed on BOTH the build server and the remote machine hosting the website. &lt;br /&gt;
    &lt;br /&gt;
    This is because; under the covers the Task queries IIS on the remote machine over AD and IIS providers are needed on the remote and the client machine.&lt;br /&gt;
    &lt;br /&gt;
    If this isn’t setup correctly you will get a ComException from DirectoryServices with an HRESULT of 0x80005000&lt;/span&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.imeta.co.uk/mnotaras/aggbug/563.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mark Notaras</dc:creator>
            <guid>http://blogs.imeta.co.uk/mnotaras/archive/2009/01/14/563.aspx</guid>
            <pubDate>Wed, 14 Jan 2009 10:01:05 GMT</pubDate>
            <wfw:comment>http://blogs.imeta.co.uk/mnotaras/comments/563.aspx</wfw:comment>
            <comments>http://blogs.imeta.co.uk/mnotaras/archive/2009/01/14/563.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.imeta.co.uk/mnotaras/comments/commentRss/563.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.imeta.co.uk/mnotaras/services/trackbacks/563.aspx</trackback:ping>
        </item>
    </channel>
</rss>