Automatic deployment with Endeavour

On the current project we are working with Endeavour 5.4. For enabling an automatic deployment with TFS build server we’ve added a custom.proj to the solution.

Within this custom.proj file commands are embedded for copying and altering sql.

<?xml version="1.0" encoding="utf-8"?>

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <!--set params here-->
  <PropertyGroup>
    <OutputDeploy>s:\deploy\febeheer</OutputDeploy>
    <TARGETdir>z:\Inetpub\wwwroot\webdirectory</TARGETdir>
    <TARGETdirForTemplate>z:\webdata</TARGETdirForTemplate>

    <SHARELogOn>(domein)\(userid)</SHARELogOn>
    <SHAREPasswrd>(password)</SHAREPasswrd>

    <RunFromComputer>SERVER</RunFromComputer>
  </PropertyGroup>

  <Choose>
      <When Condition="'$(COMPUTERNAME)'=='$(RunFromComputer)'">
        <PropertyGroup>
          <DBName>(database naam) </DBName>
          <DBServer>(naam van de database server) </DBServer>
          <DBLogOn>(userid voor inloggen in sql-server)</DBLogOn>
          <DBPasswrd>(wachtwoord behorend bij sql-user)</DBPasswrd>
        </PropertyGroup>
      </When>

    </Choose>
 
  <ItemGroup>
    <MySourceFiles Include="S:\Deliverables\$(SolutionName)\bin\_PublishedWebsites\02-Implementation\**\*.*"/>
  </ItemGroup>

 
  <Target Name="Endeavour_AfterAutoDoc">
    <CallTarget Targets="CopyFiles" Condition="'$(COMPUTERNAME)'=='$(RunFromComputer)'"/>
    <CallTarget Targets="SqlScripts" Condition="'$(COMPUTERNAME)'=='$(RunFromComputer)'"/>
    <CallTarget Targets="CopyTemplate" Condition="'$(COMPUTERNAME)'=='$(RunFromComputer)'"/>
  </Target>

 
  <!--Actual work starts from here-->
  <Target Name="CopyFiles">

    <Message Text="***** KOPIEER SLAG NAAR = $(OutputDeploy)" />
   
    <MakeDir Directories="@(OutputDeploy)"/>

    <Copy SourceFiles="@(MySourceFiles)" DestinationFiles="@(MySourceFiles->'$(OutputDeploy)\%(RecursiveDir)%(Filename)%(Extension)')" OverwriteReadOnlyFiles="true" />
    <Delete Files="$(TARGETdir)\web.DEBUG.config" />
    <Delete Files="$(TARGETdir)\web.RELEASE.config" />
    <Copy SourceFiles="S:\SupportFiles\deploy\$(SolutionName)\web.test.config" DestinationFiles="$(OutputDeploy)\web.config" OverwriteReadOnlyFiles="true" />

    <!-- Kopieer de bestanden en vervang de web.configs -->

    <Exec Command="net use Z: \\server\C$ /USER:$(SHARELogOn) $(SHAREPasswrd)" Condition="Exists('z:\')=='false'"/>

    <Copy SourceFiles="@(MySourceFiles)" DestinationFiles="$(TARGETdir)\%(RecursiveDir)%(Filename)%(Extension)" OverwriteReadOnlyFiles="true" />
    <Delete Files="$(TARGETdir)\web.DEBUG.config" />
    <Delete Files="$(TARGETdir)\web.RELEASE.config" />
    <Copy SourceFiles="S:\SupportFiles\deploy\$(SolutionName)\web.test.config" DestinationFiles="$(TARGETdir)\web.config" OverwriteReadOnlyFiles="true" />

    <Exec Command="net use Z: /DELETE" Condition="Exists('z:\')=='true'"/>

  </Target>


  <PropertyGroup>
    <TPath>C:\Program Files\MSBuild\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks</TPath>
  </PropertyGroup>
  <Import Project="$(TPath)"/>
  <Choose>
    <When Condition="Exists('S:\SupportFiles\deploy\$(SolutionName)\custom.sql') == 'true'">
      <ItemGroup>
        <InputFile Include="S:\SupportFiles\deploy\$(SolutionName)\custom.sql"/>
      </ItemGroup>
    </When>
    <When Condition="Exists('S:\SupportFiles\deploy\$(SolutionName)\InitialTestData.sql') == 'true'">
      <ItemGroup>
        <InputFile Include="S:\SupportFiles\deploy\$(SolutionName)\InitialTestData.sql"/>
      </ItemGroup>
    </When>
  </Choose>


  <!--if inputFile not empty run sql-scripts-->
  <Target Name="SqlScripts">

    <Message Text="***** DATABASE ACTIES" />

    <!-- Simple CommandLineQuery -->
    <MSBuild.ExtensionPack.SqlServer.SqlCmd TaskAction="Execute" Server="$(DBServer)" LogOn="$(DBLogOn)" Password="$(DBPasswrd)" CommandLineQuery="SELECT @@VERSION;" />
    <!-- Simple CommandLineQuery setting the Server and Database and outputing to a file -->
    <!--<MSBuild.ExtensionPack.SqlServer.SqlCmd TaskAction="Execute" Server="(local)" Database="@(DBName)" CommandLineQuery="SELECT @@VERSION;" OutputFile="C:\Output.txt"/>-->

    <!-- Simple CommandLineQuery setting the Server and Database and running external files -->
    <MSBuild.ExtensionPack.SqlServer.SqlCmd TaskAction="Execute" Server="$(DBServer)" LogOn="$(DBLogOn)" Password="$(DBPasswrd)" Database="$(DBName)" InputFiles="@(InputFile)" />

  </Target>


  <Target Name="CopyTemplate">

    <Message Text="***** KOPIEER TEMPLATE NAAR = $(TARGETdirForTemplate)" />

    <Exec Command="net use Z: \\server\C$ /USER:$(SHARELogOn) $(SHAREPasswrd)" Condition="Exists('z:\')=='false'"/>

    <MakeDir Directories="@(TARGETdirForTemplate)"/>

    <Copy SourceFiles="S:\SupportFiles\SQLXML\Template.xml" DestinationFiles="$(TARGETdirForTemplate)\ Template.xml" />

    <Exec Command="net use Z: /DELETE" Condition="Exists('z:\')=='true'"/>

  </Target>
</Project>

Geef een reactie

Je e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

*
*
*

Back To Top