Skip to content

Instantly share code, notes, and snippets.

@danieleli
Created August 25, 2011 16:11
Show Gist options
  • Save danieleli/1171055 to your computer and use it in GitHub Desktop.
Save danieleli/1171055 to your computer and use it in GitHub Desktop.
MSBuild template
<?xml version="1.0"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="BuildAndPublish"><PropertyGroup><SourceFileRootFolder>D:\Projects\SampleSite\Source</SourceFileRootFolder><ReleaseFolder>D:\Projects\SampleSite\Builds\Latest Build\Build</ReleaseFolder></PropertyGroup><ItemGroup>
<!-- This definition will be used below on the copy task -->
<SampleSiteBin Include="$(SourceFileRootFolder)\bin\**\*.*"/></ItemGroup>
<!-- Cleaning task -->
<Target Name="CleanTarget"><Message Text="Removing all source files from $(ReleaseFolder)"/><RemoveDir Directories="$(ReleaseFolder)\"/></Target>
<!-- Build and publish task -->
<Target Name="BuildAndPublish">
<!-- Building site -->
<MSBuild Targets="Clean;Build" Projects="$(SourceFileRootFolder)\SampleSite.sln"/><CallTarget Targets="CleanTarget"/>
<!-- Publishing site -->
<!-- First copying runtime files including main assembly, note the values used as targets-->
<MSBuild Targets="_CopyWebApplication;_BuiltWebOutputGroupOutput" Projects="$(SourceFileRootFolder)\SampleSite.csproj" Properties="OutDir=$(ReleaseFolder)\"/>
<!-- Now copying any file currently present on bin folder -->
<Copy DestinationFolder="$(ReleaseFolder)\_PublishedWebsites\SampleSite\bin\%(RecursiveDir)" SourceFiles="@(SampleSiteBin)"/></Target></Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment