<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(Configuration)' == 'Documentation'">
    <OutputPath>.\opentk\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <OutputPath>.\opentk\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <OutputPath>.\opentk\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Nsis'">
    <OutputPath>.\opentk\</OutputPath>
  </PropertyGroup>
  <PropertyGroup>
    <ProjectGuid>{ADC34399-7613-44D2-90B2-19250F06FE7B}</ProjectGuid>
    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    <TargetFrameworkProfile />
    <InputPath>..\..\</InputPath>
    <OutputPath>.\opentk\</OutputPath>
  </PropertyGroup>
  <Target Name="Build">
    <CallTarget Targets="CleanTreeCopy" />
    <!-- Make a clean copy of the source tree -->
    <CreateItem
        Include="$(InputPath)**\*.*"
        Exclude="$(InputPath)**\.svn\**\*.*;
                 $(InputPath)**\obj\**\*.*;
                 $(InputPath)Installers\Zip\opentk\**\*.*;
                 $(InputPath)Documentation\Source\**\*.*;
                 $(InputPath)**\OpenTK*.xml;
                 $(InputPath)**\*.suo;
                 $(InputPath)**\*.pidb;
                 $(InputPath)**\*.userprefs;
                 $(InputPath)**\opentk*.zip;
                 $(InputPath)**\opentk*.exe;
                 $(InputPath)**\vshost*.exe;
                 ">
        <Output TaskParameter="Include" ItemName="FileList" />
    </CreateItem>
    <Copy SourceFiles="@(FileList)" DestinationFiles="@(FileList->'$(OutputPath)%(RecursiveDir)%(Filename)%(Extension)')" />
    <!-- Zip the copy of the source tree -->
    <Exec Command="7z a -tzip opentk.zip $(OutputPath)" />
    <!-- Copy the zip file to the root directory and add a date stamp -->
    <ReadLinesFromFile File="../../Version.txt">
      <Output TaskParameter="Lines" ItemName="Version"/>
    </ReadLinesFromFile>
    <Copy SourceFiles=".\opentk.zip" DestinationFiles="@(Version->'..\..\opentk-%(Identity).zip')" />
  </Target>
  <Target Name="Clean">
    <CreateItem Include=".\opentk.zip;..\..\opentk-*.zip">
      <Output TaskParameter="Include" ItemName="FilesToDelete" />
    </CreateItem>
    <Delete Files="@(FilesToDelete)" />
    <CallTarget Targets="CleanTreeCopy" />
  </Target>
  <Target Name="Rebuild">
    <CallTarget Targets="Clean" />
    <CallTarget Targets="Build" />
  </Target>
  <Target Name="CleanTreeCopy">
    <RemoveDir Directories="$(OutputPath)" Condition="$(OS) == 'Windows_NT'" />
    <Exec Command="rm -rf '$(OutputPath)'" Condition="$(OS) != 'Windows_NT'" />
  </Target>
</Project>
