Friday, August 24, 2012

CI Build File and Web Application Deployment

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
         ToolsVersion="4.0"
         DefaultTargets="Compile">
  <UsingTask AssemblyFile="C:\svn\project\src\packages\ThirdParty\MSBuildCommunityTasks\AsyncExec.dll" TaskName="AsyncExec.AsyncExec"/>
  <UsingTask AssemblyFile="C:\svn\project\src\packages\ThirdParty\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.XmlRead" />
  <ItemGroup>
    <SolutionRoot Include="."/>
    <BuildArtifacts Include=".\buildartifacts\"/>
    <SolutionFile Include="..\src\Project.sln"/>
    <MsDeploy Include="..\src\packages\MSdeploy2\msdeploy.exe"/>
    <PackageFile Include=".\buildartifacts\package\Project.zip"/>
    <Website Include=".\buildartifacts\_PublishedWebsites\Project.Website"/>
  </ItemGroup>
  <Target Name="Clean">
    <RemoveDir Directories="@(BuildArtifacts)"/>
  </Target>
  <Target Name="Init" DependsOnTargets="Clean">
    <MakeDir Directories="@(BuildArtifacts)"/>
  </Target>
  <Target Name="Compile" DependsOnTargets="Init">
    <PropertyGroup>
       <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    </PropertyGroup>
    <MSBuild Projects="@(SolutionFile)" Properties="OutDir=%(BuildArtifacts.FullPath);
    Configuration=$(Configuration)"/>
  </Target>
  <Target Name="Package" DependsOnTargets="Compile">
    <PropertyGroup>
      <PackageDir>%(PackageFile.RootDir)%(PackageFile.Directory)</PackageDir>
      <Source>%(Website.FullPath)</Source>
      <Destination>%(PackageFile.FullPath)</Destination>
    </PropertyGroup>
    <MakeDir Directories="$(PackageDir)"/>
    <Exec Command='"@(MsDeploy)" -verb:sync -source:iisApp="$(Source)" -dest:package="$(Destination)"'/>
  </Target>
  <Target Name="DeployToDev" DependsOnTargets="Package">
    <PropertyGroup>
      <WebServerName>DEVSERVER</WebServerName>
      <Source>%(PackageFile.FullPath)</Source>
    </PropertyGroup>
    <Exec Command='"@(MsDeploy)" -verb:sync -source:package="$(Source)" -dest:iisApp="Default Web Site", computerName=$(WebServerName),username=,password='/>
  </Target>
</Project>

No comments: