Skip to content

Commit 6b12d86

Browse files
Johny Woller SkovdalJohny Woller Skovdal
authored andcommitted
src\Paket.Core\embedded\Paket.Restore.targets copy
to .paket\*.targets
1 parent 2af31e4 commit 6b12d86

2 files changed

Lines changed: 94 additions & 68 deletions

File tree

‎.paket/Paket.Restore.targets‎

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
<PaketBootstrapperStyle Condition="Exists('$(PaketToolsPath)paket.bootstrapper.proj')">proj</PaketBootstrapperStyle>
2121
<PaketExeImage>assembly</PaketExeImage>
2222
<PaketExeImage Condition=" '$(PaketBootstrapperStyle)' == 'proj' ">native</PaketExeImage>
23-
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
23+
<MonoPath Condition="'$(MonoPath)' == '' AND Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
2424
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
2525

2626
<!-- PaketBootStrapper -->
2727
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
2828
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
2929
<PaketBootStrapperExeDir Condition=" Exists('$(PaketBootStrapperExePath)') " >$([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\</PaketBootStrapperExeDir>
3030

31-
<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
31+
<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT' ">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
3232
<PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
3333

3434
<!-- Disable automagic references for F# dotnet sdk -->
@@ -40,55 +40,68 @@
4040
<!-- Disable Paket restore under NCrunch build -->
4141
<PaketRestoreDisabled Condition="'$(NCrunch)' == '1'">True</PaketRestoreDisabled>
4242

43+
<!-- Disable test for CLI tool completely - overrideable via properties in projects or via environment variables -->
44+
<PaketDisableCliTest Condition=" '$(PaketDisableCliTest)' == '' ">False</PaketDisableCliTest>
45+
4346
<PaketIntermediateOutputPath Condition=" '$(PaketIntermediateOutputPath)' == '' ">$(BaseIntermediateOutputPath.TrimEnd('\').TrimEnd('\/'))</PaketIntermediateOutputPath>
4447
</PropertyGroup>
4548

46-
<!-- Check if paket is available as local dotnet cli tool -->
49+
<!-- Resolve how paket should be called -->
50+
<!-- Current priority is: local (1: repo root, 2: .paket folder) => 3: as CLI tool => as bootstrapper (4: proj Bootstrapper style, 5: BootstrapperExeDir) => 6: global path variable -->
4751
<Target Name="SetPaketCommand" >
48-
49-
<!-- Call 'dotnet paket' and see if it returns without an error. Mute all the output. -->
50-
<Exec Command="dotnet paket --version" IgnoreExitCode="true" StandardOutputImportance="low" StandardErrorImportance="low" >
51-
<Output TaskParameter="ExitCode" PropertyName="LocalPaketToolExitCode" />
52-
</Exec>
52+
<!-- Test if paket is available in the standard locations. If so, that takes priority. Case 1/2 - non-windows specific -->
53+
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
54+
<!-- no windows, try native paket as default, root => tool -->
55+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket') ">$(PaketRootPath)paket</PaketExePath>
56+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketToolsPath)paket') ">$(PaketToolsPath)paket</PaketExePath>
57+
</PropertyGroup>
5358

54-
<!-- If local paket tool is found, use that -->
55-
<PropertyGroup Condition=" '$(LocalPaketToolExitCode)' == '0' ">
56-
<InternalPaketCommand>dotnet paket</InternalPaketCommand>
59+
<!-- Test if paket is available in the standard locations. If so, that takes priority. Case 2/2 - same across platforms -->
60+
<PropertyGroup>
61+
<!-- root => tool -->
62+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe') ">$(PaketRootPath)paket.exe</PaketExePath>
63+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketToolsPath)paket.exe') ">$(PaketToolsPath)paket.exe</PaketExePath>
5764
</PropertyGroup>
5865

59-
<!-- If not, then we go through our normal steps of setting the Paket command. -->
60-
<PropertyGroup Condition=" '$(LocalPaketToolExitCode)' != '0' ">
61-
<!-- windows, root => tool => proj style => bootstrapper => global -->
62-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND Exists('$(PaketRootPath)paket.exe') ">$(PaketRootPath)paket.exe</PaketExePath>
63-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND Exists('$(PaketToolsPath)paket.exe') ">$(PaketToolsPath)paket.exe</PaketExePath>
64-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND '$(PaketBootstrapperStyle)' == 'proj' ">$(PaketToolsPath)paket.exe</PaketExePath>
65-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND Exists('$(PaketBootStrapperExeDir)') ">$(_PaketBootStrapperExeDir)paket.exe</PaketExePath>
66-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' ">paket.exe</PaketExePath>
66+
<!-- If paket hasn't be found in standard locations, test for CLI tool usage. -->
67+
<!-- First test: Is CLI configured to be used in "dotnet-tools.json"? - can result in a false negative; only a positive outcome is reliable. -->
68+
<PropertyGroup Condition=" '$(PaketExePath)' == '' ">
69+
<_DotnetToolsJson Condition="Exists('$(PaketRootPath)/.config/dotnet-tools.json')">$([System.IO.File]::ReadAllText("$(PaketRootPath)/.config/dotnet-tools.json"))</_DotnetToolsJson>
70+
<_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$(_DotnetToolsJson.Contains('"paket"'))</_ConfigContainsPaket>
71+
<_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false</_ConfigContainsPaket>
72+
</PropertyGroup>
6773

68-
<!-- no windows, try native paket as default, root => tool => proj style => mono paket => bootstrpper => global -->
69-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketRootPath)paket') ">$(PaketRootPath)paket</PaketExePath>
70-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketToolsPath)paket') ">$(PaketToolsPath)paket</PaketExePath>
71-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND '$(PaketBootstrapperStyle)' == 'proj' ">$(PaketToolsPath)paket</PaketExePath>
74+
<!-- Second test: Call 'dotnet paket' and see if it returns without an error. Mute all the output. Only run if previous test failed and the test has not been disabled. -->
75+
<!-- WARNING: This method can lead to processes hanging forever, and should be used as little as possible. See https://github.com/fsprojects/Paket/issues/3705 for details. -->
76+
<Exec Condition=" '$(PaketExePath)' == '' AND !$(PaketDisableCliTest) AND !$(_ConfigContainsPaket)" Command="dotnet paket --version" IgnoreExitCode="true" StandardOutputImportance="low" StandardErrorImportance="low" >
77+
<Output TaskParameter="ExitCode" PropertyName="LocalPaketToolExitCode" />
78+
</Exec>
7279

73-
<!-- no windows, try mono paket -->
74-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketRootPath)paket.exe') ">$(PaketRootPath)paket.exe</PaketExePath>
75-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketToolsPath)paket.exe') ">$(PaketToolsPath)paket.exe</PaketExePath>
80+
<!-- If paket is installed as CLI use that. Again, only if paket haven't already been found in standard locations. -->
81+
<PropertyGroup Condition=" '$(PaketExePath)' == '' AND ($(_ConfigContainsPaket) OR '$(LocalPaketToolExitCode)' == '0') ">
82+
<_PaketCommand>dotnet paket</_PaketCommand>
83+
</PropertyGroup>
7684

77-
<!-- no windows, try bootstrapper -->
78-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketBootStrapperExeDir)') ">$(PaketBootStrapperExeDir)paket.exe</PaketExePath>
85+
<!-- If neither local files nor CLI tool can be found, final attempt is searching for boostrapper config before falling back to global path variable. -->
86+
<PropertyGroup Condition=" '$(PaketExePath)' == '' AND '$(_PaketCommand)' == '' ">
87+
<!-- Test for bootstrapper setup -->
88+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(PaketBootstrapperStyle)' == 'proj' ">$(PaketToolsPath)paket</PaketExePath>
89+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketBootStrapperExeDir)') ">$(PaketBootStrapperExeDir)paket</PaketExePath>
7990

80-
<!-- no windows, try global native paket -->
81-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' ">paket</PaketExePath>
91+
<!-- If all else fails, use global path approach. -->
92+
<PaketExePath Condition=" '$(PaketExePath)' == ''">paket</PaketExePath>
93+
</PropertyGroup>
8294

95+
<!-- If not using CLI, setup correct execution command. -->
96+
<PropertyGroup Condition=" '$(_PaketCommand)' == '' ">
8397
<_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))</_PaketExeExtension>
84-
<InternalPaketCommand Condition=" '$(InternalPaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</InternalPaketCommand>
85-
<InternalPaketCommand Condition=" '$(InternalPaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</InternalPaketCommand>
86-
<InternalPaketCommand Condition=" '$(InternalPaketCommand)' == '' ">"$(PaketExePath)"</InternalPaketCommand>
87-
98+
<_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</_PaketCommand>
99+
<_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</_PaketCommand>
100+
<_PaketCommand Condition=" '$(_PaketCommand)' == '' ">"$(PaketExePath)"</_PaketCommand>
88101
</PropertyGroup>
89102

90103
<!-- The way to get a property to be available outside the target is to use this task. -->
91-
<CreateProperty Value="$(InternalPaketCommand)">
104+
<CreateProperty Value="$(_PaketCommand)">
92105
<Output TaskParameter="Value" PropertyName="PaketCommand"/>
93106
</CreateProperty>
94107

‎.paket/paket.targets‎

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,67 @@
1010
<PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile>
1111
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
1212
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
13+
14+
<!-- Disable test for CLI tool completely - overrideable via properties in projects or via environment variables -->
15+
<PaketDisableCliTest Condition=" '$(PaketDisableCliTest)' == '' ">False</PaketDisableCliTest>
1316
</PropertyGroup>
1417

15-
<!-- Check if paket is available as local dotnet cli tool -->
18+
<!-- Resolve how paket should be called -->
19+
<!-- Current priority is: local (1: repo root, 2: .paket folder) => 3: as CLI tool => as bootstrapper (4: proj Bootstrapper style, 5: BootstrapperExeDir) => 6: global path variable -->
1620
<Target Name="SetPaketCommand" >
21+
<!-- Test if paket is available in the standard locations. If so, that takes priority. Case 1/2 - non-windows specific -->
22+
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
23+
<!-- no windows, try native paket as default, root => tool -->
24+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket') ">$(PaketRootPath)paket</PaketExePath>
25+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketToolsPath)paket') ">$(PaketToolsPath)paket</PaketExePath>
26+
</PropertyGroup>
1727

18-
<!-- Call 'dotnet paket' and see if it returns without an error. Mute all the output. -->
19-
<Exec Command="dotnet paket --version" IgnoreExitCode="true" StandardOutputImportance="low" StandardErrorImportance="low" >
20-
<Output TaskParameter="ExitCode" PropertyName="LocalPaketToolExitCode" />
21-
</Exec>
22-
23-
<!-- If local paket tool is found, use that -->
24-
<PropertyGroup Condition=" '$(LocalPaketToolExitCode)' == '0' ">
25-
<InternalPaketCommand>dotnet paket</InternalPaketCommand>
28+
<!-- Test if paket is available in the standard locations. If so, that takes priority. Case 2/2 - same across platforms -->
29+
<PropertyGroup>
30+
<!-- root => tool -->
31+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe') ">$(PaketRootPath)paket.exe</PaketExePath>
32+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketToolsPath)paket.exe') ">$(PaketToolsPath)paket.exe</PaketExePath>
2633
</PropertyGroup>
2734

28-
<!-- If not, then we go through our normal steps of setting the Paket command. -->
29-
<PropertyGroup Condition=" '$(LocalPaketToolExitCode)' != '0' ">
30-
<!-- windows, root => tool => proj style => bootstrapper => global -->
31-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND Exists('$(PaketRootPath)paket.exe') ">$(PaketRootPath)paket.exe</PaketExePath>
32-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND Exists('$(PaketToolsPath)paket.exe') ">$(PaketToolsPath)paket.exe</PaketExePath>
33-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND '$(PaketBootstrapperStyle)' == 'proj' ">$(PaketToolsPath)paket.exe</PaketExePath>
34-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND Exists('$(PaketBootStrapperExeDir)') ">$(_PaketBootStrapperExeDir)paket.exe</PaketExePath>
35-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' ">paket.exe</PaketExePath>
35+
<!-- If paket hasn't be found in standard locations, test for CLI tool usage. -->
36+
<!-- First test: Is CLI configured to be used in "dotnet-tools.json"? - can result in a false negative; only a positive outcome is reliable. -->
37+
<PropertyGroup Condition=" '$(PaketExePath)' == '' ">
38+
<_DotnetToolsJson Condition="Exists('$(PaketRootPath)/.config/dotnet-tools.json')">$([System.IO.File]::ReadAllText("$(PaketRootPath)/.config/dotnet-tools.json"))</_DotnetToolsJson>
39+
<_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$(_DotnetToolsJson.Contains('"paket"'))</_ConfigContainsPaket>
40+
<_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false</_ConfigContainsPaket>
41+
</PropertyGroup>
3642

37-
<!-- no windows, try native paket as default, root => tool => proj style => mono paket => bootstrpper => global -->
38-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketRootPath)paket') ">$(PaketRootPath)paket</PaketExePath>
39-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketToolsPath)paket') ">$(PaketToolsPath)paket</PaketExePath>
40-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND '$(PaketBootstrapperStyle)' == 'proj' ">$(PaketToolsPath)paket</PaketExePath>
43+
<!-- Second test: Call 'dotnet paket' and see if it returns without an error. Mute all the output. Only run if previous test failed and the test has not been disabled. -->
44+
<!-- WARNING: This method can lead to processes hanging forever, and should be used as little as possible. See https://github.com/fsprojects/Paket/issues/3705 for details. -->
45+
<Exec Condition=" '$(PaketExePath)' == '' AND !$(PaketDisableCliTest) AND !$(_ConfigContainsPaket)" Command="dotnet paket --version" IgnoreExitCode="true" StandardOutputImportance="low" StandardErrorImportance="low" >
46+
<Output TaskParameter="ExitCode" PropertyName="LocalPaketToolExitCode" />
47+
</Exec>
4148

42-
<!-- no windows, try mono paket -->
43-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketRootPath)paket.exe') ">$(PaketRootPath)paket.exe</PaketExePath>
44-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketToolsPath)paket.exe') ">$(PaketToolsPath)paket.exe</PaketExePath>
49+
<!-- If paket is installed as CLI use that. Again, only if paket haven't already been found in standard locations. -->
50+
<PropertyGroup Condition=" '$(PaketExePath)' == '' AND ($(_ConfigContainsPaket) OR '$(LocalPaketToolExitCode)' == '0') ">
51+
<_PaketCommand>dotnet paket</_PaketCommand>
52+
</PropertyGroup>
4553

46-
<!-- no windows, try bootstrapper -->
47-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketBootStrapperExeDir)') ">$(PaketBootStrapperExeDir)paket.exe</PaketExePath>
54+
<!-- If neither local files nor CLI tool can be found, final attempt is searching for boostrapper config before falling back to global path variable. -->
55+
<PropertyGroup Condition=" '$(PaketExePath)' == '' AND '$(_PaketCommand)' == '' ">
56+
<!-- Test for bootstrapper setup -->
57+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(PaketBootstrapperStyle)' == 'proj' ">$(PaketToolsPath)paket</PaketExePath>
58+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketBootStrapperExeDir)') ">$(PaketBootStrapperExeDir)paket</PaketExePath>
4859

49-
<!-- no windows, try global native paket -->
50-
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' ">paket</PaketExePath>
60+
<!-- If all else fails, use global path approach. -->
61+
<PaketExePath Condition=" '$(PaketExePath)' == ''">paket</PaketExePath>
62+
</PropertyGroup>
5163

64+
<!-- If not using CLI, setup correct execution command. -->
65+
<PropertyGroup Condition=" '$(_PaketCommand)' == '' ">
5266
<_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))</_PaketExeExtension>
53-
<InternalPaketCommand Condition=" '$(InternalPaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</InternalPaketCommand>
54-
<InternalPaketCommand Condition=" '$(InternalPaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</InternalPaketCommand>
55-
<InternalPaketCommand Condition=" '$(InternalPaketCommand)' == '' ">"$(PaketExePath)"</InternalPaketCommand>
56-
67+
<_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</_PaketCommand>
68+
<_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</_PaketCommand>
69+
<_PaketCommand Condition=" '$(_PaketCommand)' == '' ">"$(PaketExePath)"</_PaketCommand>
5770
</PropertyGroup>
5871

5972
<!-- The way to get a property to be available outside the target is to use this task. -->
60-
<CreateProperty Value="$(InternalPaketCommand)">
73+
<CreateProperty Value="$(_PaketCommand)">
6174
<Output TaskParameter="Value" PropertyName="PaketCommand"/>
6275
</CreateProperty>
6376

0 commit comments

Comments
 (0)