<!--
 *
 * Eagle.targets -
 *
 * WARNING: Contains more evil MSBuild hacks than your doctor recommended.
 *
 * Copyright (c) 2007-2012 by Joe Mistachkin.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: $
 *
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!--
  ******************************************************************************
  **                          Load Per-User Settings                          **
  ******************************************************************************
  -->

  <!--
      NOTE: If the per-user settings file exists, import it now.  The contained
            settings, if any, will override the default ones provided below.
  -->
  <Import Condition="'$(EagleDir)' != '' And
                     !HasTrailingSlash('$(EagleDir)') And
                     Exists('$(EagleDir)\Targets\Eagle.targets.user')"
          Project="$(EagleDir)\Targets\Eagle.targets.user" />

  <!--
  ******************************************************************************
  **                               Hack Targets                               **
  ******************************************************************************
  -->

  <Target Name="FixCopyFilesToOutputDirectory"
          Condition="'$(BuildTool)' == 'MSBuild'"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).FixCopyFilesToOutputDirectory.done">
    <!--
        HACK: No "Inputs" or "Outputs" were specified on the built-in
              CopyFilesToOutputDirectory target?

        RANT: This hack totally sucks and should not be required, period.  I
              blame Microsoft.  This bug should never have been allowed to
              escape the campus.  The built-in MSBuild task
              CopyFilesToOutputDirectory is fundamentally broken for any
              non-trivial builds (especially those that need to post-process the
              target assembly for things such as digital signatures) and needs
              to be fixed.  However, even if it gets fixed, this hack must now
              remain here forever because we want to support the .NET Framework
              2.0 RTM as it was shipped.  This message has been brought to you
              by a developer who spent far too long debugging this ridiculous
              MSBuild issue until he finally observed which task was responsible
              and googled it.
    -->
    <Copy SourceFiles="$(TargetPath)"
          DestinationFiles="@(IntermediateAssembly)"
          SkipUnchangedFiles="true" />

    <Copy SourceFiles="$(OutDir)$(TargetName).pdb"
          DestinationFiles="$(IntermediateOutputPath)$(TargetName).pdb"
          SkipUnchangedFiles="true"
          Condition="'$(_DebugSymbolsProduced)' == 'true'" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).FixCopyFilesToOutputDirectory.done" />
  </Target>

  <!--
  ******************************************************************************
  **                           Housekeeping Targets                           **
  ******************************************************************************
  -->

  <Target Name="CleanDoneFiles"
          Condition="'$(OutDir)' != '' And
                     '$(TargetFileName)' != ''">
    <CreateItem Include="$(OutDir)$(TargetFileName).*.done">
      <Output ItemName="OldDoneFiles" TaskParameter="Include" />
    </CreateItem>

    <Delete Condition="'@(OldDoneFiles)' != ''"
            Files="@(OldDoneFiles)" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="GetDoneFiles"
          Condition="'$(OutDir)' != '' And
                     '$(TargetFileName)' != ''">
    <CreateItem Include="$(OutDir)$(TargetFileName).*.done">
      <Output ItemName="NewDoneFiles" TaskParameter="Include" />
    </CreateItem>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="UpdateDoneFiles"
          Inputs="$(TargetPath)"
          Outputs="@(NewDoneFiles)">
    <!--
        NOTE: We know that we performed all the tasks if they were necessary.
              However, since we have multiple tasks that all potentially update
              the target path, we need to resync the "*.done" files to the final
              time-stamp of the target path so that we do not accidentally
              trigger any of the tasks that rely upon them during a later build.
    -->
    <Touch Files="@(NewDoneFiles)" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="CleanConfigurations"
          Condition="'$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)')">
    <CreateItem Include="$(OutputPath)*.config">
      <Output ItemName="ConfigurationFiles" TaskParameter="Include" />
    </CreateItem>

    <Delete Condition="'@(ConfigurationFiles)' != ''"
            Files="@(ConfigurationFiles)" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="CleanWixOutputFiles"
          Condition="'$(MSBuildProjectDirectory)' != '' And
                     !HasTrailingSlash('$(MSBuildProjectDirectory)')">
    <CreateItem Include="$(MSBuildProjectDirectory)\Tests\*.msi;$(MSBuildProjectDirectory)\Tests\*.wixobj;$(MSBuildProjectDirectory)\Tests\*.wixpdb">
      <Output ItemName="WixOutputFiles" TaskParameter="Include" />
    </CreateItem>

    <Delete Condition="'@(WixOutputFiles)' != ''"
            Files="@(WixOutputFiles)" />
  </Target>

  <!--
  ******************************************************************************
  **                         [Fairly] Generic Targets                         **
  ******************************************************************************
  -->

  <Target Name="StrongNameSign"
          Condition="'$(SignAssembly)' != 'false' And
                     '$(BuildTool)' == 'MSBuild' And
                     '$(OperatingSystem)' == 'Windows' And
                     Exists('$(AssemblyOriginatorKeyFile)') And
                     Exists('$(AssemblyPrivateKeyFile)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).StrongNameSign.done">
    <!--
        HACK: *BROKEN* The GetFrameworkSDKPath MSBuild task was broken by the
              Visual Studio 2012 / .NET Framework 4.5 RTM release.  It now
              incorrectly returns the Windows SDK path, not the .NET Framework
              SDK path.  When Visual Studio 2012 is installed, it also breaks
              the Visual Studio 2010 / .NET Framework 4.0 build environment as
              well.  The "supported", yet sub-optimal, alternative appears to
              be using the TargetFrameworkSDKToolsDirectory variable.
    -->
    <GetFrameworkSDKPath Condition="('$(StrongNameWithoutSdk)' == '' Or
                                     '$(StrongNameWithoutSdk)' == 'false') And
                                    '$(TargetFrameworkSDKToolsDirectory)' == ''">
      <Output TaskParameter="Path"
              PropertyName="DirForStrongName" />
    </GetFrameworkSDKPath>

    <Exec Condition="'$(StrongNameWithoutSdk)' != '' And
                     '$(StrongNameWithoutSdk)' != 'false'"
          Command="sn.exe -Ra &quot;$(TargetPath)&quot; &quot;$(AssemblyPrivateKeyFile)&quot;" />

    <Exec Condition="('$(StrongNameWithoutSdk)' == '' Or
                      '$(StrongNameWithoutSdk)' == 'false') And
                     '$(TargetFrameworkSDKToolsDirectory)' == '' And
                     '$(DirForStrongName)' != '' And
                     HasTrailingSlash('$(DirForStrongName)') And
                     Exists('$(DirForStrongName)bin\sn.exe')"
          Command="&quot;$(DirForStrongName)bin\sn.exe&quot; -Ra &quot;$(TargetPath)&quot; &quot;$(AssemblyPrivateKeyFile)&quot;" />

    <Exec Condition="('$(StrongNameWithoutSdk)' == '' Or
                      '$(StrongNameWithoutSdk)' == 'false') And
                     '$(TargetFrameworkSDKToolsDirectory)' != '' And
                     '$(DirForStrongName)' == '' And
                     HasTrailingSlash('$(TargetFrameworkSDKToolsDirectory)') And
                     Exists('$(TargetFrameworkSDKToolsDirectory)sn.exe')"
          Command="&quot;$(TargetFrameworkSDKToolsDirectory)sn.exe&quot; -Ra &quot;$(TargetPath)&quot; &quot;$(AssemblyPrivateKeyFile)&quot;" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).StrongNameSign.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="Mark32BitOnly"
          Condition="'$(Mark32BitOnly)' != 'false' And
                     '$(BuildTool)' == 'MSBuild' And
                     '$(OperatingSystem)' == 'Windows'"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).Mark32BitOnly.done">
    <!--
        HACK: *BROKEN* The GetFrameworkSDKPath MSBuild task was broken by the
              Visual Studio 2012 / .NET Framework 4.5 RTM release.  It now
              incorrectly returns the Windows SDK path, not the .NET Framework
              SDK path.  When Visual Studio 2012 is installed, it also breaks
              the Visual Studio 2010 / .NET Framework 4.0 build environment as
              well.  The "supported", yet sub-optimal, alternative appears to
              be using the TargetFrameworkSDKToolsDirectory variable.
    -->
    <GetFrameworkSDKPath Condition="'$(TargetFrameworkSDKToolsDirectory)' == ''">
      <Output TaskParameter="Path"
              PropertyName="DirForMark32BitOnly" />
    </GetFrameworkSDKPath>

    <Exec Condition="'$(TargetFrameworkSDKToolsDirectory)' == '' And
                     '$(DirForMark32BitOnly)' != '' And
                     HasTrailingSlash('$(DirForMark32BitOnly)') And
                     Exists('$(DirForMark32BitOnly)bin\CorFlags.exe')"
          Command="&quot;$(DirForMark32BitOnly)bin\CorFlags.exe&quot; &quot;$(TargetPath)&quot; /32BIT+ /Force" />

    <Exec Condition="'$(TargetFrameworkSDKToolsDirectory)' != '' And
                     '$(DirForMark32BitOnly)' == '' And
                     HasTrailingSlash('$(TargetFrameworkSDKToolsDirectory)') And
                     Exists('$(TargetFrameworkSDKToolsDirectory)CorFlags.exe')"
          Command="&quot;$(TargetFrameworkSDKToolsDirectory)CorFlags.exe&quot; &quot;$(TargetPath)&quot; /32BIT+ /Force" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).Mark32BitOnly.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="CopyPkgIndex"
          Condition="'$(CopyPkgIndex)' != 'false' And
                     '$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyPkgIndex.done">
    <CreateItem Include="lib\pkgIndex.*">
      <Output ItemName="PkgIndexFiles" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(PkgIndexFiles)"
          DestinationFolder="$(OutputPath)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyPkgIndex.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="CopyTools"
          Condition="'$(CopyTools)' != 'false' And
                     '$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyTools.done">
    <CreateItem Include="Tools\*">
      <Output ItemName="ToolFiles" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(ToolFiles)"
          DestinationFolder="$(OutputPath)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyTools.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="CopyLibrary"
          Condition="'$(CopyLibrary)' != 'false' And
                     '$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyLibrary.done">
    <CreateItem Include="lib\**">
      <Output ItemName="LibraryFiles" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(LibraryFiles)"
          DestinationFiles="@(LibraryFiles->'$(OutputPath)%(RecursiveDir)%(Filename)%(Extension)')" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyLibrary.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="CopyExternals"
          Condition="'$(CopyExternals)' != 'false' And
                     '$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyExternals.done">
    <CreateItem Include="Externals\*" Exclude="Externals\no_*">
      <Output ItemName="ExternalFiles" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(ExternalFiles)"
          DestinationFolder="$(OutputPath)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyExternals.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="CopyArchitectureExternals"
          Condition="'$(CopyArchitectureExternals)' != 'false' And
                     '$(Architecture)' != '' And
                     '$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyArchitectureExternals.done">
    <CreateItem Include="Externals\$(Architecture)\*"
                Exclude="Externals\$(Architecture)\no_*">
      <Output ItemName="ArchitectureExternalFiles" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(ArchitectureExternalFiles)"
          DestinationFolder="$(OutputPath)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyArchitectureExternals.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="CopyAllArchitectureExternals"
          Condition="'$(CopyAllArchitectureExternals)' != 'false' And
                     '$(Architecture)' != '' And
                     '$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyAllArchitectureExternals.done">
    <CreateItem Include="Externals\**\$(Architecture)\*"
                Exclude="Externals\**\$(Architecture)\no_*">
      <Output ItemName="AllArchitectureExternalFiles" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(AllArchitectureExternalFiles)"
          DestinationFolder="$(OutputPath)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyAllArchitectureExternals.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="CopyConfigurations"
          Condition="'$(CopyConfigurations)' != 'false' And
                     '$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyConfigurations.done">
    <CreateItem Include="Configurations\*.config" Exclude="Configurations\no_*">
      <Output ItemName="ConfigurationFiles" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(ConfigurationFiles)"
          DestinationFolder="$(OutputPath)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyConfigurations.done" />
  </Target>

  <!--
  ******************************************************************************
  **                          Eagle Specific Targets                          **
  ******************************************************************************
  -->

  <Target Name="EagleDetectBuildTool"
          Condition="'$(EagleDetectBuildTool)' != 'false' And
                     '$(MSBuildBinPath)' != '' And
                     !HasTrailingSlash('$(MSBuildBinPath)')">
    <CreateProperty Condition="Exists('$(MSBuildBinPath)\MSBuild.exe')"
                    Value="MSBuild">
      <Output TaskParameter="Value" PropertyName="BuildTool" />
    </CreateProperty>

    <CreateProperty Condition="Exists('$(MSBuildBinPath)\xbuild.exe')"
                    Value="XBuild">
      <Output TaskParameter="Value" PropertyName="BuildTool" />
    </CreateProperty>

    <CreateProperty Condition="!Exists('$(MSBuildBinPath)\MSBuild.exe') And
                               !Exists('$(MSBuildBinPath)\xbuild.exe')"
                    Value="Unknown">
      <Output TaskParameter="Value" PropertyName="BuildTool" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectOperatingSystem"
          Condition="'$(EagleDetectOperatingSystem)' != 'false'">
    <CreateProperty Condition="'$(OS)' == 'Windows_NT'" Value="Windows">
      <Output TaskParameter="Value" PropertyName="OperatingSystem" />
    </CreateProperty>

    <CreateProperty Condition="'$(OS)' == 'Unix'" Value="Unix">
      <Output TaskParameter="Value" PropertyName="OperatingSystem" />
    </CreateProperty>

    <CreateProperty Condition="'$(OS)' == 'OSX'" Value="MacOSX">
      <Output TaskParameter="Value" PropertyName="OperatingSystem" />
    </CreateProperty>

    <CreateProperty Condition="'$(OS)' != 'Windows_NT' And
                               '$(OS)' != 'Unix' And
                               '$(OS)' != 'OSX'"
                    Value="Unknown">
      <Output TaskParameter="Value" PropertyName="OperatingSystem" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectArchitecture"
          Condition="'$(EagleDetectArchitecture)' != 'false'">
    <CreateProperty Condition="'$(PROCESSOR_ARCHITECTURE)' == 'AMD64' Or
                               '$(PROCESSOR_ARCHITEW6432)' == 'AMD64'"
                    Value="x64">
      <Output TaskParameter="Value" PropertyName="Architecture" />
    </CreateProperty>

    <CreateProperty Condition="'$(PROCESSOR_ARCHITECTURE)' == 'IA64' Or
                               '$(PROCESSOR_ARCHITEW6432)' == 'IA64'"
                    Value="ia64">
      <Output TaskParameter="Value" PropertyName="Architecture" />
    </CreateProperty>

    <CreateProperty Condition="'$(PROCESSOR_ARCHITECTURE)' == 'x86' And
                               '$(PROCESSOR_ARCHITEW6432)' == ''"
                    Value="x86">
      <Output TaskParameter="Value" PropertyName="Architecture" />
    </CreateProperty>

    <CreateProperty Condition="'$(PROCESSOR_ARCHITECTURE)' == 'ARM' And
                               '$(PROCESSOR_ARCHITEW6432)' == ''"
                    Value="arm">
      <Output TaskParameter="Value" PropertyName="Architecture" />
    </CreateProperty>

    <CreateProperty Condition="'$(PROCESSOR_ARCHITECTURE)' != 'AMD64' And
                               '$(PROCESSOR_ARCHITECTURE)' != 'IA64' And
                               '$(PROCESSOR_ARCHITECTURE)' != 'x86' And
                               '$(PROCESSOR_ARCHITECTURE)' != 'ARM'"
                    Value="Unknown">
      <Output TaskParameter="Value" PropertyName="Architecture" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectNetFx20Sp"
          Condition="'$(EagleDetectNetFx20Sp)' != 'false' And
                     '$(BuildTool)' == 'MSBuild' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleLibraryToolsDir)' != '' And
                     HasTrailingSlash('$(EagleLibraryToolsDir)') And
                     Exists('$(EagleLibraryToolsDir)SetErrorLevel.exe') And
                     Exists('$(EagleLibraryToolsDir)netFx20Sp.bat')">
    <Exec Command="&quot;$(EagleLibraryToolsDir)netFx20Sp.bat&quot;"
          IgnoreExitCode="true">
      <Output TaskParameter="ExitCode" PropertyName="EagleNetFx20Sp"/>
    </Exec>

    <CreateProperty Condition="$(EagleNetFx20Sp) &gt;= 0x201"
                    Value="$(DefineConstants);NET_20_SP1">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>

    <CreateProperty Condition="$(EagleNetFx20Sp) &gt;= 0x202"
                    Value="$(DefineConstants);NET_20_SP2">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectNetFx20"
          Condition="'$(EagleDetectNetFx20)' != 'false'">
    <CreateProperty Condition="(('$(MSBuildToolsVersion)' == '' Or
                                 '$(MSBuildToolsVersion)' == '2.0' Or
                                 '$(MSBuildToolsVersion)' == '3.5') And
                                '$(TargetFrameworkVersion)' == '') Or
                               '$(TargetFrameworkVersion)' == 'v2.0'"
                    Value="$(DefineConstants);NET_20">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>

    <CreateProperty Condition="(('$(MSBuildToolsVersion)' != '' And
                                 '$(MSBuildToolsVersion)' != '2.0' And
                                 '$(MSBuildToolsVersion)' != '3.5') Or
                                '$(TargetFrameworkVersion)' != '') And
                               '$(TargetFrameworkVersion)' != 'v2.0'"
                    Value="false">
      <Output TaskParameter="Value" PropertyName="EagleDetectNetFx20Sp" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectNetFx30"
          Condition="'$(EagleDetectNetFx30)' != 'false'">
    <CreateProperty Condition="'$(TargetFrameworkVersion)' == 'v3.0'"
                    Value="$(DefineConstants);NET_30">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectNetFx35"
          Condition="'$(EagleDetectNetFx35)' != 'false'">
    <CreateProperty Condition="'$(TargetFrameworkVersion)' == 'v3.5'"
                    Value="$(DefineConstants);NET_35">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectNetFx40"
          Condition="'$(EagleDetectNetFx40)' != 'false'">
    <CreateProperty Condition="('$(MSBuildToolsVersion)' == '4.0' And
                                '$(TargetFrameworkVersion)' == '') Or
                               '$(TargetFrameworkVersion)' == 'v4.0' Or
                               '$(TargetFrameworkVersion)' == 'v4.5' Or
                               '$(TargetFrameworkVersion)' == 'v4.5.1' Or
                               '$(TargetFrameworkVersion)' == 'v4.5.2'"
                    Value="$(DefineConstants);NET_40">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectNetFx45"
          Condition="'$(EagleDetectNetFx45)' != 'false'">
    <CreateProperty Condition="'$(TargetFrameworkVersion)' == 'v4.5'"
                    Value="$(DefineConstants);NET_45">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectNetFx451"
          Condition="'$(EagleDetectNetFx451)' != 'false'">
    <CreateProperty Condition="'$(TargetFrameworkVersion)' == 'v4.5.1'"
                    Value="$(DefineConstants);NET_451">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectNetFx452"
          Condition="'$(EagleDetectNetFx452)' != 'false'">
    <CreateProperty Condition="'$(TargetFrameworkVersion)' == 'v4.5.2'"
                    Value="$(DefineConstants);NET_452">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectWix30"
          Condition="'$(EagleDetectWix30)' != 'false'">
    <CreateProperty Condition="'$(EagleWixVersion)' == '3.0'"
                    Value="$(DefineConstants);WIX_30">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectWix35"
          Condition="'$(EagleDetectWix35)' != 'false'">
    <CreateProperty Condition="'$(EagleWixVersion)' == '3.5'"
                    Value="$(DefineConstants);WIX_35">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectWix36"
          Condition="'$(EagleDetectWix36)' != 'false'">
    <CreateProperty Condition="'$(EagleWixVersion)' == '3.6'"
                    Value="$(DefineConstants);WIX_36">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectWix37"
          Condition="'$(EagleDetectWix37)' != 'false'">
    <CreateProperty Condition="'$(EagleWixVersion)' == '3.7'"
                    Value="$(DefineConstants);WIX_37">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectWix38"
          Condition="'$(EagleDetectWix38)' != 'false'">
    <CreateProperty Condition="'$(EagleWixVersion)' == '3.8'"
                    Value="$(DefineConstants);WIX_38">
      <Output TaskParameter="Value" PropertyName="DefineConstants" />
    </CreateProperty>
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleSetStack2005"
          Condition="'$(EagleSetStack)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleStackSize)' != '' And
                     '$(VS80COMNTOOLS)' != '' And
                     HasTrailingSlash('$(VS80COMNTOOLS)') And
                     Exists('$(VS80COMNTOOLS)..\..\VC\bin\EditBin.exe')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).SetStack.done">
    <Exec Command="&quot;$(VS80COMNTOOLS)..\..\VC\bin\EditBin.exe&quot; &quot;/stack:$(EagleStackSize)&quot; &quot;$(TargetPath)&quot;"
          WorkingDirectory="$(VS80COMNTOOLS)..\..\Common7\IDE" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).SetStack.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleSetStack2008"
          Condition="'$(EagleSetStack)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleStackSize)' != '' And
                     '$(VS90COMNTOOLS)' != '' And
                     HasTrailingSlash('$(VS90COMNTOOLS)') And
                     Exists('$(VS90COMNTOOLS)..\..\VC\bin\EditBin.exe')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).SetStack.done">
    <Exec Command="&quot;$(VS90COMNTOOLS)..\..\VC\bin\EditBin.exe&quot; &quot;/stack:$(EagleStackSize)&quot; &quot;$(TargetPath)&quot;"
          WorkingDirectory="$(VS90COMNTOOLS)..\..\Common7\IDE" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).SetStack.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleSetStack2010"
          Condition="'$(EagleSetStack)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleStackSize)' != '' And
                     '$(VS100COMNTOOLS)' != '' And
                     HasTrailingSlash('$(VS100COMNTOOLS)') And
                     Exists('$(VS100COMNTOOLS)..\..\VC\bin\EditBin.exe')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).SetStack.done">
    <Exec Command="&quot;$(VS100COMNTOOLS)..\..\VC\bin\EditBin.exe&quot; &quot;/stack:$(EagleStackSize)&quot; &quot;$(TargetPath)&quot;"
          WorkingDirectory="$(VS100COMNTOOLS)..\..\Common7\IDE" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).SetStack.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleSetStack2012"
          Condition="'$(EagleSetStack)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleStackSize)' != '' And
                     '$(VS110COMNTOOLS)' != '' And
                     HasTrailingSlash('$(VS110COMNTOOLS)') And
                     Exists('$(VS110COMNTOOLS)..\..\VC\bin\EditBin.exe')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).SetStack.done">
    <Exec Command="&quot;$(VS110COMNTOOLS)..\..\VC\bin\EditBin.exe&quot; &quot;/stack:$(EagleStackSize)&quot; &quot;$(TargetPath)&quot;"
          WorkingDirectory="$(VS110COMNTOOLS)..\..\Common7\IDE" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).SetStack.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleSetStack2013"
          Condition="'$(EagleSetStack)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleStackSize)' != '' And
                     '$(VS120COMNTOOLS)' != '' And
                     HasTrailingSlash('$(VS120COMNTOOLS)') And
                     Exists('$(VS120COMNTOOLS)..\..\VC\bin\EditBin.exe')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).SetStack.done">
    <Exec Command="&quot;$(VS120COMNTOOLS)..\..\VC\bin\EditBin.exe&quot; &quot;/stack:$(EagleStackSize)&quot; &quot;$(TargetPath)&quot;"
          WorkingDirectory="$(VS120COMNTOOLS)..\..\Common7\IDE" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).SetStack.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleSetIcon"
          Condition="'$(EagleSetIcon)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleLibraryDir)' != '' And
                     '$(EagleLibraryToolsDir)' != '' And
                     HasTrailingSlash('$(EagleLibraryDir)') And
                     HasTrailingSlash('$(EagleLibraryToolsDir)') And
                     Exists('$(EagleLibraryToolsDir)SetIcon.exe') And
                     Exists('$(EagleLibraryDir)Resources\Eagle.ico')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).SetIcon.done">
    <Exec Command="&quot;$(EagleLibraryToolsDir)SetIcon.exe&quot; &quot;$(TargetPath)&quot; &quot;$(EagleLibraryDir)Resources\Eagle.ico&quot;" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).SetIcon.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleStripPdbPath"
          Condition="'$(EagleStripPdbPath)' != 'false' And
                     '$(BuildTool)' == 'MSBuild' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleLibraryDir)' != '' And
                     '$(EagleLibraryToolsDir)' != '' And
                     HasTrailingSlash('$(EagleLibraryDir)') And
                     HasTrailingSlash('$(EagleLibraryToolsDir)') And
                     Exists('$(EagleLibraryToolsDir)BinaryEditor.exe')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).StripPdbPath.done">
    <!--
        HACK: *WARNING* This is really evil.  Basically, we [attempt to] modify
              the built executable image to remove the directory information for
              the PDB file name in the "Debug Directory" header.  There seems to
              be no other [easy] way to accomplish this, official or otherwise.
    -->
    <Exec Command="&quot;$(EagleLibraryToolsDir)BinaryEditor.exe&quot; -noCase -paths -verbose -- &quot;$(TargetPath)&quot; &quot;$(TargetPath)&quot; &quot;$(IntermediateOutputPath)$(TargetName).pdb&quot; &quot;$(TargetName).pdb&quot;" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).StripPdbPath.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleEmbedExeManifest"
          Condition="'$(EagleEmbedExeManifest)' != 'false' And
                     '$(BuildTool)' == 'MSBuild' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(MSBuildProjectDirectory)' != '' And
                     !HasTrailingSlash('$(MSBuildProjectDirectory)') And
                     Exists('$(MSBuildProjectDirectory)\Resources\manifest.xml')"
          Inputs="$(TargetPath);$(MSBuildProjectDirectory)\Resources\manifest.xml"
          Outputs="$(TargetPath).EmbedExeManifest.done">
    <!--
        HACK: *BROKEN* The GetFrameworkSDKPath MSBuild task was broken by the
              Visual Studio 2012 / .NET Framework 4.5 RTM release.  It now
              incorrectly returns the Windows SDK path, not the .NET Framework
              SDK path.  When Visual Studio 2012 is installed, it also breaks
              the Visual Studio 2010 / .NET Framework 4.0 build environment as
              well.  The "supported", yet sub-optimal, alternative appears to
              be using the TargetFrameworkSDKToolsDirectory variable.
    -->
    <GetFrameworkSDKPath Condition="'$(WindowsSDK80Path)' == ''">
      <Output TaskParameter="Path"
              PropertyName="DirForManifestTool" />
    </GetFrameworkSDKPath>

    <Exec Condition="'$(WindowsSDK80Path)' == '' And
                     '$(DirForManifestTool)' != '' And
                     HasTrailingSlash('$(DirForManifestTool)') And
                     Exists('$(DirForManifestTool)bin\mt.exe')"
          Command="&quot;$(DirForManifestTool)bin\mt.exe&quot; -manifest &quot;$(MSBuildProjectDirectory)\Resources\manifest.xml&quot; -outputresource:&quot;$(TargetPath)&quot;;1" />

    <Exec Condition="'$(WindowsSDK80Path)' != '' And
                     '$(DirForManifestTool)' == '' And
                     '$(Architecture)' != '' And
                     Exists('$(WindowsSDK80Path)bin\$(Architecture)\mt.exe')"
          Command="&quot;$(WindowsSDK80Path)bin\$(Architecture)\mt.exe&quot; -manifest &quot;$(MSBuildProjectDirectory)\Resources\manifest.xml&quot; -outputresource:&quot;$(TargetPath)&quot;;1" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).EmbedExeManifest.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleStrongNameSign"
          Condition="'$(EagleStrongNameSign)' != 'false' And
                     '$(BuildTool)' == 'MSBuild' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(SignAssembly)' != 'false' And
                     Exists('$(AssemblyOriginatorKeyFile)') And
                     Exists('$(EaglePrivateKeyFile)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).StrongNameSign.done">
    <!--
        HACK: *BROKEN* The GetFrameworkSDKPath MSBuild task was broken by the
              Visual Studio 2012 / .NET Framework 4.5 RTM release.  It now
              incorrectly returns the Windows SDK path, not the .NET Framework
              SDK path.  When Visual Studio 2012 is installed, it also breaks
              the Visual Studio 2010 / .NET Framework 4.0 build environment as
              well.  The "supported", yet sub-optimal, alternative appears to
              be using the TargetFrameworkSDKToolsDirectory variable.
    -->
    <GetFrameworkSDKPath Condition="('$(StrongNameWithoutSdk)' == '' Or
                                     '$(StrongNameWithoutSdk)' == 'false') And
                                    '$(TargetFrameworkSDKToolsDirectory)' == ''">
      <Output TaskParameter="Path"
              PropertyName="DirForStrongName" />
    </GetFrameworkSDKPath>

    <Exec Condition="'$(StrongNameWithoutSdk)' != '' And
                     '$(StrongNameWithoutSdk)' != 'false'"
          Command="sn.exe -Ra &quot;$(TargetPath)&quot; &quot;$(EaglePrivateKeyFile)&quot;" />

    <Exec Condition="('$(StrongNameWithoutSdk)' == '' Or
                      '$(StrongNameWithoutSdk)' == 'false') And
                     '$(TargetFrameworkSDKToolsDirectory)' == '' And
                     '$(DirForStrongName)' != '' And
                     HasTrailingSlash('$(DirForStrongName)') And
                     Exists('$(DirForStrongName)bin\sn.exe')"
          Command="&quot;$(DirForStrongName)bin\sn.exe&quot; -Ra &quot;$(TargetPath)&quot; &quot;$(EaglePrivateKeyFile)&quot;" />

    <Exec Condition="('$(StrongNameWithoutSdk)' == '' Or
                      '$(StrongNameWithoutSdk)' == 'false') And
                     '$(TargetFrameworkSDKToolsDirectory)' != '' And
                     '$(DirForStrongName)' == '' And
                     HasTrailingSlash('$(TargetFrameworkSDKToolsDirectory)') And
                     Exists('$(TargetFrameworkSDKToolsDirectory)sn.exe')"
          Command="&quot;$(TargetFrameworkSDKToolsDirectory)sn.exe&quot; -Ra &quot;$(TargetPath)&quot; &quot;$(EaglePrivateKeyFile)&quot;" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).StrongNameSign.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleAuthenticodeSign"
          Condition="'$(EagleAuthenticodeSign)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     Exists('$(SPC_FILE)') And
                     Exists('$(PVK_FILE)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).AuthenticodeSign.done">
    <Exec Condition="'$(EagleLibraryToolsDir)' != '' And
                     HasTrailingSlash('$(EagleLibraryToolsDir)') And
                     Exists('$(EagleLibraryToolsDir)SignCode.exe')"
          Command="&quot;$(EagleLibraryToolsDir)SignCode.exe&quot; -spc &quot;$(SPC_FILE)&quot; -v &quot;$(PVK_FILE)&quot; -n &quot;$(EagleProjectName)&quot; -i &quot;$(EagleProjectUrl)&quot; -a sha1 -t &quot;$(EagleTimeStampUrl)&quot; -tr &quot;$(EagleTimeStampRetries)&quot; -tw &quot;$(EagleTimeStampWait)&quot; &quot;$(TargetPath)&quot;" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).AuthenticodeSign.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleShellRun"
          Condition="'$(EagleShellRun)' != 'false' And
                     '$(BuildTool)' == 'MSBuild' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(Configuration)' != '' And
                     '$(EagleDir)' != '' And
                     !HasTrailingSlash('$(EagleDir)') And
                     Exists('$(EagleDir)\bin\$(Configuration)\bin\EagleShell.exe')">
    <Exec Command="start &quot;&quot; &quot;$(EagleDir)\bin\$(Configuration)\bin\EagleShell.exe&quot;" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCleanShellExe"
          Condition="'$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)') And
                     Exists('$(OutputPath)es.exe')">
    <Delete Files="$(OutputPath)es.exe" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCleanPackage"
          Condition="'$(EaglePackageOutputPath)' != '' And
                     HasTrailingSlash('$(EaglePackageOutputPath)') And
                     Exists('$(EaglePackageOutputPath)')">
    <CreateItem Include="$(EaglePackageOutputPath)**">
      <Output ItemName="PackageFiles" TaskParameter="Include" />
    </CreateItem>

    <Delete Condition="'@(PackageFiles)' != ''"
            Files="@(PackageFiles)" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCleanTasks"
          Condition="'$(EagleBinaryOutputPath)' != '' And
                     HasTrailingSlash('$(EagleBinaryOutputPath)') And
                     Exists('$(EagleBinaryOutputPath)')">
    <CreateItem Include="$(EagleBinaryOutputPath)*.tasks">
      <Output ItemName="TaskFiles" TaskParameter="Include" />
    </CreateItem>

    <Delete Condition="'@(TaskFiles)' != ''"
            Files="@(TaskFiles)" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCleanWebConfigurations"
          Condition="'$(MSBuildProjectDirectory)' != '' And
                     !HasTrailingSlash('$(MSBuildProjectDirectory)')">
    <CreateItem Include="$(MSBuildProjectDirectory)\*.config">
      <Output ItemName="ConfigurationFiles" TaskParameter="Include" />
    </CreateItem>

    <Delete Condition="'@(ConfigurationFiles)' != ''"
            Files="@(ConfigurationFiles)" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCleanBuildTasks"
          Condition="'$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)') And
                     Exists('$(OutputPath)BuildTasks')">
    <CreateItem Include="$(OutputPath)BuildTasks\$(TargetFileName);$(OutputPath)BuildTasks\*.tasks">
      <Output ItemName="BuildTaskFiles" TaskParameter="Include" />
    </CreateItem>

    <Delete Condition="'@(BuildTaskFiles)' != ''"
            Files="@(BuildTaskFiles)"
            ContinueOnError="true" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCopyBuildTasks"
          Condition="'$(EagleCopyBuildTasks)' != 'false' And
                     '$(EagleDir)' != '' And
                     '$(OutputPath)' != '' And
                     !HasTrailingSlash('$(EagleDir)') And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(EagleDir)') And
                     Exists('$(OutputPath)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyBuildTasks.done">
    <CreateItem Include="$(EagleDir)\Targets\*.tasks">
      <Output ItemName="TaskFiles" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(TaskFiles)"
          DestinationFolder="$(OutputPath)" />

    <Copy SourceFiles="@(TaskFiles)"
          DestinationFolder="$(OutputPath)BuildTasks" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyBuildTasks.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCopyDllToBuildTasks"
          Condition="'$(EagleCopyDllToBuildTasks)' != 'false' And
                     '$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyDllToBuildTasks.done">
    <Copy SourceFiles="$(TargetPath)"
          DestinationFolder="$(OutputPath)BuildTasks"
          ContinueOnError="true" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyDllToBuildTasks.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCopyShellExe"
          Condition="'$(EagleCopyShellExe)' != 'false' And
                     '$(OutputPath)' != '' And
                     HasTrailingSlash('$(OutputPath)') And
                     Exists('$(OutputPath)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyShellExe.done">
    <Copy SourceFiles="$(TargetPath)"
          DestinationFiles="$(OutputPath)es.exe" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyShellExe.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCopySQLite3"
          Condition="'$(EagleCopySQLite3)' != 'false' And
                     '$(Architecture)' != '' And
                     '$(MSBuildProjectDirectory)' != '' And
                     !HasTrailingSlash('$(MSBuildProjectDirectory)') And
                     '$(EagleDir)' != '' And
                     !HasTrailingSlash('$(EagleDir)') And
                     '$(EagleBinaryOutputPath)' != '' And
                     HasTrailingSlash('$(EagleBinaryOutputPath)') And
                     Exists('$(EagleBinaryOutputPath)') And
                     Exists('$(EagleDir)\Externals\sqlite3\$(Architecture)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopySQLite3.done">
    <CreateItem Include="$(EagleDir)\Externals\sqlite3\$(Architecture)\*">
      <Output ItemName="SQLite3Files" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(SQLite3Files)"
          DestinationFolder="$(EagleBinaryOutputPath)$(Architecture)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopySQLite3.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCopySystemDataSQLite"
          Condition="'$(EagleCopySystemDataSQLite)' != 'false' And
                     '$(MSBuildProjectDirectory)' != '' And
                     !HasTrailingSlash('$(MSBuildProjectDirectory)') And
                     '$(EagleBinaryOutputPath)' != '' And
                     HasTrailingSlash('$(EagleBinaryOutputPath)') And
                     Exists('$(EagleBinaryOutputPath)') And
                     Exists('$(EagleDir)\Externals\System.Data.SQLite')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopySystemDataSQLite.done">
    <CreateItem Include="$(EagleDir)\Externals\System.Data.SQLite\*">
      <Output ItemName="SystemDataSQLiteFiles" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(SystemDataSQLiteFiles)"
          DestinationFolder="$(EagleBinaryOutputPath)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopySystemDataSQLite.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleCopyWebConfigurations"
          Condition="'$(EagleCopyWebConfigurations)' != 'false' And
                     '$(MSBuildProjectDirectory)' != '' And
                     !HasTrailingSlash('$(MSBuildProjectDirectory)')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).CopyWebConfigurations.done">
    <!--
        HACK: Apparently, Visual Studio cannot cope with the "Web.config" file
              not being directly in the project directory; therefore, copy it
              there now.
    -->
    <CreateItem Include="Configurations\*.config" Exclude="Configurations\no_*">
      <Output ItemName="ConfigurationFiles" TaskParameter="Include" />
    </CreateItem>

    <Copy SourceFiles="@(ConfigurationFiles)"
          DestinationFolder="$(MSBuildProjectDirectory)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).CopyWebConfigurations.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectUserBuilds"
          Condition="'$(EagleDetectUserBuilds)' != 'false' And
                     '$(EagleUserBuilds)' != ''">
    <Warning Text="One or more user build overrides may be in effect." />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleDetectUserSettings"
          Condition="'$(EagleDetectUserSettings)' != 'false' And
                     '$(EagleUserSettings)' != ''">
    <Warning Text="One or more user setting overrides may be in effect." />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="MissingShell"
          Condition="'$(ProjectName)' != ''">
    <Warning Text="Shell support is disabled, skipping project &quot;$(ProjectName)&quot;..." />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="MissingConsole"
          Condition="'$(ProjectName)' != ''">
    <Warning Text="Console support is disabled, skipping project &quot;$(ProjectName)&quot;..." />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="MissingXml"
          Condition="'$(ProjectName)' != ''">
    <Warning Text="The &quot;System.Xml&quot; assembly is disabled, skipping project &quot;$(ProjectName)&quot;..." />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="MissingNativeCodeAndOrTclIntegration"
          Condition="'$(ProjectName)' != ''">
    <Warning Text="Native code and/or Tcl integration are disabled, skipping project &quot;$(ProjectName)&quot;..." />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="MissingWinForms"
          Condition="'$(ProjectName)' != ''">
    <Warning Text="WinForms support is disabled, skipping project &quot;$(ProjectName)&quot;..." />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="MissingSystemManagementAutomation"
          Condition="'$(ProjectName)' != ''">
    <Warning Text="The &quot;System.Management.Automation&quot; assembly could not be located, skipping project &quot;$(ProjectName)&quot;..." />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="MissingWebApplicationProjects"
          Condition="'$(ProjectName)' != ''">
    <Warning Text="The &quot;Microsoft.WebApplication.targets&quot; file could not be located, skipping project &quot;$(ProjectName)&quot;..." />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="MissingWix"
          Condition="'$(ProjectName)' != ''">
    <Warning Text="The &quot;WiX&quot; and/or &quot;Microsoft.Deployment.WindowsInstaller&quot; assemblies could not be located, skipping project &quot;$(ProjectName)&quot;..." />
  </Target>

  <!--
  ******************************************************************************
  **                      Eagle Library Specific Targets                      **
  ******************************************************************************
  -->

  <Target Name="EagleMsgGenUnsetReadOnly"
          Condition="'$(EagleMsgGen)' != 'false' And
                     '$(EagleUnsetReadOnly)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(SystemRoot)' != '' And
                     !HasTrailingSlash('$(SystemRoot)') And
                     Exists('$(SystemRoot)\System32\attrib.exe')"
          Inputs="Messages\messages.xml"
          Outputs="Generated\messages.cs;Generated\messages.resources">
    <Exec Condition="Exists('Generated\messages.cs')"
          Command="&quot;$(SystemRoot)\System32\attrib.exe&quot; -r Generated\messages.cs" />

    <Exec Condition="Exists('Generated\messages.resources')"
          Command="&quot;$(SystemRoot)\System32\attrib.exe&quot; -r Generated\messages.resources" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleMessagesResGenUnsetReadOnly"
          Condition="'$(EagleMessagesResGen)' != 'false' And
                     '$(EagleUnsetReadOnly)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(SystemRoot)' != '' And
                     !HasTrailingSlash('$(SystemRoot)') And
                     Exists('$(SystemRoot)\System32\attrib.exe')"
          Inputs="Resources\messages.resx"
          Outputs="Resources\messages.resources">
    <Exec Condition="Exists('Resources\messages.resources')"
          Command="&quot;$(SystemRoot)\System32\attrib.exe&quot; -r Resources\messages.resources" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleLibraryResGenUnsetReadOnly"
          Condition="'$(EagleLibraryResGen)' != 'false' And
                     '$(EagleUnsetReadOnly)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleEmbeddedLibrary)' != 'false' And
                     '$(SystemRoot)' != '' And
                     !HasTrailingSlash('$(SystemRoot)') And
                     Exists('$(SystemRoot)\System32\attrib.exe')"
          Inputs="Resources\library.resx;..\lib\Eagle1.0\init.eagle;
                  ..\lib\Eagle1.0\embed.eagle;..\lib\Eagle1.0\safe.eagle;
                  ..\lib\Eagle1.0\shell.eagle;..\lib\Eagle1.0\test.eagle;
                  ..\lib\Eagle1.0\vendor.eagle;..\lib\Eagle1.0\word.tcl;
                  ..\lib\Eagle1.0\pkgIndex.eagle"
          Outputs="Resources\library.resources">
    <Exec Condition="Exists('Resources\library.resources')"
          Command="&quot;$(SystemRoot)\System32\attrib.exe&quot; -r Resources\library.resources" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleMsgGen"
          Condition="'$(EagleMsgGen)' != 'false' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleLibraryToolsDir)' != '' And
                     HasTrailingSlash('$(EagleLibraryToolsDir)') And
                     Exists('$(EagleLibraryToolsDir)MsgGen.exe')"
          Inputs="Messages\messages.xml"
          Outputs="Generated\messages.cs;Generated\messages.resources">
    <MakeDir Directories="Generated" />

    <Exec Command="&quot;$(EagleLibraryToolsDir)MsgGen.exe&quot; Messages\messages.xml Generated\messages.cs Generated\messages.resources" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleMessagesResGen"
          Condition="'$(EagleMessagesResGen)' != 'false'"
          Inputs="Resources\messages.resx"
          Outputs="Resources\messages.resources">
    <GenerateResource Sources="Resources\messages.resx"
                      OutputResources="Resources\messages.resources" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <!--
      NOTE: *WARNING* Be sure to update the "Inputs" attribute here and the list
            of files in the file "Library\Resources\library.resx" if any files
            are added to the script library.
  -->
  <Target Name="EagleLibraryResGen"
          Condition="'$(EagleLibraryResGen)' != 'false' And
                     '$(EagleEmbeddedLibrary)' != 'false'"
          Inputs="Resources\library.resx;..\lib\Eagle1.0\init.eagle;
                  ..\lib\Eagle1.0\embed.eagle;..\lib\Eagle1.0\safe.eagle;
                  ..\lib\Eagle1.0\shell.eagle;..\lib\Eagle1.0\test.eagle;
                  ..\lib\Eagle1.0\vendor.eagle;..\lib\Eagle1.0\word.tcl;
                  ..\lib\Eagle1.0\pkgIndex.eagle"
          Outputs="Resources\library.resources">
    <GenerateResource Sources="Resources\library.resx"
                      OutputResources="Resources\library.resources" />
  </Target>

  <!--
  ******************************************************************************
  **                       Eagle Test Specific Targets                        **
  ******************************************************************************
  -->

  <Target Name="EagleRunTests"
          Condition="'$(EagleRunTests)' != 'false' And
                     '$(BuildTool)' == 'MSBuild' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(EagleLibraryDir)' != '' And
                     HasTrailingSlash('$(EagleLibraryDir)') And
                     Exists('$(EagleLibraryDir)') And
                     Exists('$(EagleLibraryDir)Tests\all.eagle')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).RunTests.done">
    <Exec Condition="'$(EagleRunCoverage)' == 'false' Or
                     '$(EagleCoverageTool)' == '' Or
                     !Exists('$(EagleCoverageTool)') Or
                     '$(EagleCoverageOutputPath)' == '' Or
                     '$(EagleCoverageArguments)' == ''"
          Command="&quot;$(TargetPath)&quot; $(EagleCommonTestArguments) $(EagleTestArguments) -file &quot;$(EagleLibraryDir)Tests\all.eagle&quot; $(EagleTestFlags)" />

    <Exec Condition="'$(EagleRunCoverage)' != 'false' And
                     '$(EagleCoverageTool)' != '' And
                     Exists('$(EagleCoverageTool)') And
                     '$(EagleCoverageOutputPath)' != '' And
                     '$(EagleCoverageArguments)' != ''"
          Command="&quot;$(EagleCoverageTool)&quot; &quot;$(TargetPath)&quot; $(EagleCommonTestArguments) $(EagleTestArguments) -file &quot;$(EagleLibraryDir)Tests\all.eagle&quot; $(EagleTestFlags) $(EagleCoverageArguments)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).RunTests.done" />
  </Target>

  <!--
  ******************************************************************************
  -->

  <Target Name="EagleShellRunTests"
          Condition="'$(EagleShellRunTests)' != 'false' And
                     '$(BuildTool)' == 'MSBuild' And
                     '$(OperatingSystem)' == 'Windows' And
                     '$(Configuration)' != '' And
                     '$(MSBuildProjectDirectory)' != '' And
                     !HasTrailingSlash('$(MSBuildProjectDirectory)') And
                     '$(EagleDir)' != '' And
                     !HasTrailingSlash('$(EagleDir)') And
                     Exists('$(EagleDir)\bin\$(Configuration)\bin\EagleShell.exe') And
                     Exists('$(MSBuildProjectDirectory)\Tests\all.eagle')"
          Inputs="$(TargetPath)"
          Outputs="$(TargetPath).ShellRunTests.done">
    <Exec Condition="'$(EagleRunCoverage)' == 'false' Or
                     !Exists('$(EagleCoverageTool)')"
          Command="&quot;$(EagleDir)\bin\$(Configuration)\bin\EagleShell.exe&quot; $(EagleCommonTestArguments) $(EagleTestArguments) -file &quot;$(MSBuildProjectDirectory)\Tests\all.eagle&quot; $(EagleTestFlags)" />

    <Exec Condition="'$(EagleRunCoverage)' != 'false' And
                     Exists('$(EagleCoverageTool)')"
          Command="&quot;$(EagleCoverageTool)&quot; &quot;$(EagleDir)\bin\$(Configuration)\bin\EagleShell.exe&quot; $(EagleCommonTestArguments) $(EagleTestArguments) -file &quot;$(MSBuildProjectDirectory)\Tests\all.eagle&quot; $(EagleTestFlags) $(EagleCoverageArguments)" />

    <Touch AlwaysCreate="true"
           Files="$(TargetPath).ShellRunTests.done" />
  </Target>
</Project>
