Created
September 29, 2014 15:55
-
-
Save ctaggart/77706d81703f241dd1c7 to your computer and use it in GitHub Desktop.
paket.targets using MSBuildThisFileDirectory https://github.com/fsprojects/Paket/issues/172
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<PropertyGroup> | |
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir> | |
<!-- Enable the restore command to run before builds --> | |
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages> | |
<!-- Download Paket.exe if it does not already exist --> | |
<DownloadPaket Condition=" '$(DownloadPaket)' == '' ">true</DownloadPaket> | |
</PropertyGroup> | |
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'"> | |
<!-- Windows specific commands --> | |
<!--<PaketToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".paket"))</PaketToolsPath>--> | |
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath> | |
</PropertyGroup> | |
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'"> | |
<!-- We need to launch paket.exe with the mono command if we're not on windows --> | |
<PaketToolsPath>$(SolutionDir).paket</PaketToolsPath> | |
</PropertyGroup> | |
<PropertyGroup> | |
<!-- Paket command --> | |
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath> | |
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath> | |
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand> | |
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(PaketExePath)</PaketCommand> | |
<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand> | |
<PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(PaketBootStrapperExePath)</PaketBootStrapperCommand> | |
<!-- Commands --> | |
<RestoreCommand>$(PaketCommand) install</RestoreCommand> | |
<DownloadPaketCommand>$(PaketBootStrapperCommand) </DownloadPaketCommand> | |
<!-- We need to ensure packages are restored prior to assembly resolve --> | |
<BuildDependsOn Condition="$(RestorePackages) == 'true'"> | |
RestorePackages; | |
$(BuildDependsOn); | |
</BuildDependsOn> | |
</PropertyGroup> | |
<Target Name="CheckPrerequisites"> | |
<!-- Raise an error if we're unable to locate paket.exe --> | |
<Error Condition="'$(DownloadPaket)' != 'true' AND !Exists('$(PaketExePath)')" Text="Unable to locate '$(PaketExePath)'" /> | |
<!-- | |
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download paket.exe once. | |
This effectively acts as a lock that makes sure that the download operation will only happen once and all | |
parallel builds will have to wait for it to complete. | |
--> | |
<MsBuild Targets="DownloadPaket" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadPaket=$(DownloadPaket)" /> | |
</Target> | |
<Target Name="DownloadPaket"> | |
<Exec Command="$(DownloadPaketCommand)" Condition=" '$(DownloadPaket)' == 'true' AND !Exists('$(PaketExePath)')" /> | |
</Target> | |
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites"> | |
<Exec Command="$(RestoreCommand)" | |
WorkingDirectory="$(SolutionDir)" /> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment