|
1 | 1 | <?xml version="1.0" encoding="utf-8"?>
|
2 | 2 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
| 3 | + |
3 | 4 | <PropertyGroup>
|
4 | 5 | <!-- Enable the restore command to run before builds -->
|
5 | 6 | <RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
|
6 |
| - <!-- Download Paket.exe if it does not already exist --> |
7 |
| - <DownloadPaket Condition=" '$(DownloadPaket)' == '' ">true</DownloadPaket> |
8 | 7 | <PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
|
9 | 8 | <PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
|
| 9 | + <PaketLockFilePath>$(PaketRootPath)paket.lock</PaketLockFilePath> |
| 10 | + <PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile> |
10 | 11 | <MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
|
11 | 12 | <MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
|
12 | 13 | </PropertyGroup>
|
| 14 | + |
13 | 15 | <PropertyGroup>
|
14 | 16 | <!-- Paket command -->
|
| 17 | + <PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath> |
15 | 18 | <PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
|
16 |
| - <PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath> |
17 | 19 | <PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
|
18 | 20 | <PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
|
19 |
| - <PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketBootStrapperExePath)" $(PaketBootStrapperCommandArgs)</PaketBootStrapperCommand> |
20 |
| - <PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 $(PaketBootStrapperExePath) $(PaketBootStrapperCommandArgs)</PaketBootStrapperCommand> |
21 |
| - <!-- Commands --> |
22 |
| - <PaketReferences Condition="!Exists('$(MSBuildProjectFullPath).paket.references')">$(MSBuildProjectDirectory)\paket.references</PaketReferences> |
23 |
| - <PaketReferences Condition="!Exists('$(PaketReferences)')">$(MSBuildStartupDirectory)\paket.references</PaketReferences> |
24 |
| - <PaketReferences Condition="Exists('$(MSBuildProjectFullPath).paket.references')">$(MSBuildProjectFullPath).paket.references</PaketReferences> |
25 |
| - <RestoreCommand>$(PaketCommand) restore --references-files "$(PaketReferences)"</RestoreCommand> |
26 |
| - <DownloadPaketCommand>$(PaketBootStrapperCommand)</DownloadPaketCommand> |
| 21 | + </PropertyGroup> |
| 22 | + |
| 23 | + <Choose> <!-- MyProject.fsproj.paket.references has the highest precedence --> |
| 24 | + <When Condition="Exists('$(MSBuildProjectFullPath).paket.references')"> |
| 25 | + <PropertyGroup> |
| 26 | + <PaketReferences>$(MSBuildProjectFullPath).paket.references</PaketReferences> |
| 27 | + </PropertyGroup> |
| 28 | + </When> <!-- MyProject.paket.references --> |
| 29 | + <When Condition="Exists('$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references')"> |
| 30 | + <PropertyGroup> |
| 31 | + <PaketReferences>$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketReferences> |
| 32 | + </PropertyGroup> |
| 33 | + </When> <!-- paket.references --> |
| 34 | + <When Condition="Exists('$(MSBuildProjectDirectory)\paket.references')"> |
| 35 | + <PropertyGroup> |
| 36 | + <PaketReferences>$(MSBuildProjectDirectory)\paket.references</PaketReferences> |
| 37 | + </PropertyGroup> |
| 38 | + </When> <!-- Set to empty if a reference file isn't found matching one of the 3 format options --> |
| 39 | + <Otherwise> |
| 40 | + <PropertyGroup> |
| 41 | + <PaketReferences></PaketReferences> |
| 42 | + </PropertyGroup> |
| 43 | + </Otherwise> |
| 44 | + </Choose> |
| 45 | + |
| 46 | + <PropertyGroup> |
| 47 | + <!-- Commands --> |
| 48 | + <RestoreCommand>$(PaketCommand) restore --references-file "$(PaketReferences)"</RestoreCommand> |
27 | 49 | <!-- We need to ensure packages are restored prior to assembly resolve -->
|
28 | 50 | <BuildDependsOn Condition="$(RestorePackages) == 'true'">RestorePackages; $(BuildDependsOn);</BuildDependsOn>
|
29 | 51 | </PropertyGroup>
|
30 |
| - <Target Name="CheckPrerequisites"> |
31 |
| - <!-- Raise an error if we're unable to locate paket.exe --> |
32 |
| - <Error Condition="'$(DownloadPaket)' != 'true' AND !Exists('$(PaketExePath)')" Text="Unable to locate '$(PaketExePath)'" /> |
33 |
| - <MsBuild Targets="DownloadPaket" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadPaket=$(DownloadPaket)" /> |
34 |
| - </Target> |
35 |
| - <Target Name="DownloadPaket"> |
36 |
| - <Exec Command="$(DownloadPaketCommand)" IgnoreStandardErrorWarningFormat="true" Condition=" '$(DownloadPaket)' == 'true' AND !Exists('$(PaketExePath)')" /> |
37 |
| - </Target> |
38 |
| - <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites"> |
39 |
| - <Exec Command="$(RestoreCommand)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(PaketRootPath)" Condition="Exists('$(PaketReferences)')" ContinueOnError="true" /> |
| 52 | + <Target Name="RestorePackages"> |
| 53 | + <PropertyGroup> |
| 54 | + <PaketRestoreRequired>true</PaketRestoreRequired> |
| 55 | + </PropertyGroup> |
| 56 | + |
| 57 | + <PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') "> |
| 58 | + <PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash> |
| 59 | + <PaketRestoreLockFileHash>$([System.IO.File]::ReadAllText('$(PaketLockFilePath)'))</PaketRestoreLockFileHash> |
| 60 | + <PaketRestoreRequired>true</PaketRestoreRequired> |
| 61 | + <PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired> |
| 62 | + <PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired> |
| 63 | + </PropertyGroup> |
| 64 | + |
| 65 | + <Exec Command="$(RestoreCommand)" |
| 66 | + IgnoreStandardErrorWarningFormat="true" |
| 67 | + WorkingDirectory="$(PaketRootPath)" |
| 68 | + ContinueOnError="false" |
| 69 | + Condition=" '$(PaketRestoreRequired)' == 'true' AND Exists('$(PaketReferences)') AND '$(PaketReferences)' != '' " |
| 70 | + /> |
40 | 71 | </Target>
|
41 | 72 | </Project>
|
0 commit comments