<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="CopyUmbracoFilesToWebRootForDeploy" AfterTargets="CopyAllFilesToSingleFolderForMsdeploy">
    <PropertyGroup>
      <UmbracoFilesFolder>$(MSBuildThisFileDirectory)..\UmbracoFiles\</UmbracoFilesFolder>
    </PropertyGroup>
    <ItemGroup>
      <UmbracoFiles Include="$(UmbracoFilesFolder)**\*" />
    </ItemGroup>
    <Copy SourceFiles="%(UmbracoFiles.FullPath)" DestinationFiles="$(_PackageTempDir)\%(RecursiveDir)%(Filename)%(Extension)" Condition="!Exists('%(RecursiveDir)%(Filename)%(Extension)')" />
  </Target>  
  <Target Name="CopyUmbracoFilesToWebRoot" BeforeTargets="AfterBuild">
	<!-- This copies the files listed in `AddUmbracoFilesToOutput` to the webroot during NuGet install and should -->
	<!-- not be altered to support automated builds, use `CopyUmbracoFilesToWebRootForDeploy` for that instead -->
    <PropertyGroup>
      <UmbracoFilesFolder>$(MSBuildThisFileDirectory)..\UmbracoFiles\</UmbracoFilesFolder>
    </PropertyGroup>
    <ItemGroup>
      <UmbracoFiles Include="$(UmbracoFilesFolder)**\*" />
    </ItemGroup>
    <Copy SourceFiles="%(UmbracoFiles.FullPath)" DestinationFiles="%(RecursiveDir)%(Filename)%(Extension)" Condition="!Exists('%(RecursiveDir)%(Filename)%(Extension)')" />
  </Target>
  <Target Name="AddUmbracoFilesToOutput">
    <!-- With help from: http://blog.samstephens.co.nz/2010-10-18/msbuild-including-extra-files-multiple-builds/ -->
    <ItemGroup>
      <CustomFilesToInclude Include=".\App_Browsers\**\*">
        <Dir>App_Browsers</Dir>
      </CustomFilesToInclude>
      <CustomFilesToInclude Include=".\App_Code\**\*">
        <Dir>App_Code</Dir>
      </CustomFilesToInclude>
      <CustomFilesToInclude Include=".\App_Plugins\**\*">
        <Dir>App_Plugins</Dir>
      </CustomFilesToInclude>
      <CustomFilesToInclude Include=".\bin\amd64\**\*">
        <Dir>bin\amd64</Dir>
      </CustomFilesToInclude>
      <CustomFilesToInclude Include=".\bin\x86\**\*">
        <Dir>bin\x86</Dir>
      </CustomFilesToInclude>
      <CustomFilesToInclude Include=".\Config\Splashes\**\*">
        <Dir>Config\Splashes</Dir>
      </CustomFilesToInclude>
      <CustomFilesToInclude Include=".\data\**\*">
        <Dir>data</Dir>
      </CustomFilesToInclude>
      <CustomFilesToInclude Include=".\umbraco\**\*">
        <Dir>umbraco</Dir>
      </CustomFilesToInclude>
      <CustomFilesToInclude Include=".\Global.asax">
        <Dir>.</Dir>
      </CustomFilesToInclude>
      <FilesForPackagingFromProject Include="@(CustomFilesToInclude)">
        <DestinationRelativePath>%(CustomFilesToInclude.Dir)\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
</Project>
