Skip to content

Instantly share code, notes, and snippets.

@tucaz
Created May 6, 2010 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tucaz/392612 to your computer and use it in GitHub Desktop.
Save tucaz/392612 to your computer and use it in GitHub Desktop.
<Project DefaultTargets="Run" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- ### Import non-default tasks do be used in this build file ### -->
<!--SDC Tasks Library - Open Source pack from: http://sdctasks.codeplex.com/-->
<Import Project="Microsoft.Sdc.Common.tasks"/>
<!-- FTP Task - Open Source task from: http://www.digizzle.com/Projects/FtpTask/Docs.aspx#ftptask -->
<UsingTask AssemblyFile="FtpTask.dll" TaskName="FtpTask"/>
<!-- ### 0 - This is the entry point of this build file. Run all tasks in the correct order ### -->
<Target Name="Run">
<CallTarget Targets="Clean" />
<CallTarget Targets="Compile" />
<CallTarget Targets="Publish" />
<CallTarget Targets="FTPUpload1" />
<CallTarget Targets="FTPUpload2" />
</Target>
<!-- ### 1 - Set properties used during deploy ### -->
<Target Name="SetProperties">
<!-- Indicates what is the directory where the source code is: one level above this build file -->
<CreateItem Include="$(MSBuildProjectDirectory)\..">
<Output TaskParameter="Include" ItemName="SourceCodeDirectory" />
</CreateItem>
<!-- Indicates what folder should be used as output folder from the build process -->
<CreateItem Include="$(MSBuildProjectDirectory)\output">
<Output TaskParameter="Include" ItemName="OutputDirectory" />
</CreateItem>
</Target>
<!-- ### 2 - Run a "Clean" command in the entire solution to remove old files ### -->
<Target Name="Clean" DependsOnTargets="SetProperties">
<Message Text="Starting to clean Solution" />
<MSBuild Projects="%(SourceCodeDirectory.FullPath)\HNI.Portal.sln" Targets="Clean">
</MSBuild>
<Message Text="Solution cleaned" />
</Target>
<!-- ### 3 - Build the web project ### -->
<Target Name="Compile" DependsOnTargets="SetProperties">
<Message Text="Start to compile solution" />
<MSBuild Projects="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\HNI.Portal.UI.csproj" StopOnFirstFailure="True" Targets="Build" Properties="Configuration=Release;">
</MSBuild>
<Message Text="Solution compiled" />
</Target>
<!--### 4 - Since there is no MSBuild task that works as "Publish" command we do it manually, task by task
and output all assemblies and pages to $(OutputDirectory) -->
<Target Name="Publish" DependsOnTargets="SetProperties">
<PropertyGroup>
<OutputDir>%(OutputDirectory.FullPath)</OutputDir>
</PropertyGroup>
<!-- Create a list of files that will be copied to the output directory -->
<ItemGroup>
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.dll" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.aspx" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.asmx" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.ashx" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.jpg" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.gif" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.png" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.bmp" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.js" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.css" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.config" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.master" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.html" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.htm" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.asax" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.resx" />
<File Include="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\**\*.ascx" />
</ItemGroup>
<!-- Removes the output directory to make sure it is clean -->
<RemoveDir Directories="$(OutputDir)">
</RemoveDir>
<!-- Then we create it -->
<MakeDir Directories="$(OutputDir)">
</MakeDir>
<!-- Use this task to copy all the references needed by the web project -->
<MSBuild Projects="%(SourceCodeDirectory.FullPath)\HNI.Portal.UI\HNI.Portal.UI.csproj" Properties="" Targets="ResolveReferences" ContinueOnError="false" StopOnFirstFailure="true" />
<!-- Copy files defined up there to the output directory -->
<Copy SourceFiles="@(File)" DestinationFiles="@(File-&gt;'$(OutputDir)\%(RecursiveDir)\%(Filename)%(Extension)')" />
<Message Text="Solution published to local folder" />
</Target>
<!-- ### 5 - Deploy all files from the OutputDirectory to QA Server 1 ### -->
<Target Name="FTPUpload1">
<Message Text="Starting to FTP to QA Server 1" />
<FtpTask
Action="CleanupAndUpload"
Address="qa.server1.com"
RemoteDir="/remoteDirectory
LocalDir="$(OutputDir)"
UserName="FTPUser"
Password="FTPPassword"
/>
<Message Text="Finished FTP to QA Server 1" />
</Target>
<!-- ### 6 - Deploy all files from the OutputDirectory to QA Server 2 ### -->
<Target Name="FTPUpload2">
<Message Text="Starting to FTP to QA Server 2" />
<FtpTask
Action="CleanupAndUpload"
Address="qa.server2.com"
RemoteDir="/remoteDirectory"
LocalDir="$(OutputDir)"
UserName="FTPUser"
Password="FTPPassword"
/>
<Message Text="Finished FTP to QA Server 2" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment