|
7 | 7 | <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> |
8 | 8 |
|
9 | 9 | <DetectedMSBuildVersion>$(MSBuildVersion)</DetectedMSBuildVersion> |
10 | | - <DetectedMSBuildVersion Condition="$(MSBuildVersion) == ''">15.0.0</DetectedMSBuildVersion> |
| 10 | + <DetectedMSBuildVersion Condition="'$(MSBuildVersion)' == ''">15.0.0</DetectedMSBuildVersion> |
11 | 11 | <MSBuildSupportsHashing>false</MSBuildSupportsHashing> |
12 | 12 | <MSBuildSupportsHashing Condition=" '$(DetectedMSBuildVersion)' > '15.8.0' ">true</MSBuildSupportsHashing> |
13 | 13 | <!-- Mark that this target file has been loaded. --> |
|
20 | 20 | <PaketBootstrapperStyle Condition="Exists('$(PaketToolsPath)paket.bootstrapper.proj')">proj</PaketBootstrapperStyle> |
21 | 21 | <PaketExeImage>assembly</PaketExeImage> |
22 | 22 | <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> |
24 | 24 | <MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath> |
25 | 25 |
|
26 | 26 | <!-- PaketBootStrapper --> |
27 | 27 | <PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath> |
28 | 28 | <PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath> |
29 | 29 | <PaketBootStrapperExeDir Condition=" Exists('$(PaketBootStrapperExePath)') " >$([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\</PaketBootStrapperExeDir> |
30 | 30 |
|
31 | | - <!-- Paket --> |
32 | | - |
33 | | - <!-- windows, root => tool => proj style => bootstrapper => global --> |
34 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND Exists('$(PaketRootPath)paket.exe') ">$(PaketRootPath)paket.exe</PaketExePath> |
35 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND Exists('$(PaketToolsPath)paket.exe') ">$(PaketToolsPath)paket.exe</PaketExePath> |
36 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND '$(PaketBootstrapperStyle)' == 'proj' ">$(PaketToolsPath)paket.exe</PaketExePath> |
37 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' AND Exists('$(PaketBootStrapperExeDir)') ">$(_PaketBootStrapperExeDir)paket.exe</PaketExePath> |
38 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' == 'Windows_NT' ">paket.exe</PaketExePath> |
39 | | - |
40 | | - <!-- no windows, try native paket as default, root => tool => proj style => mono paket => bootstrpper => global --> |
41 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketRootPath)paket') ">$(PaketRootPath)paket</PaketExePath> |
42 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketToolsPath)paket') ">$(PaketToolsPath)paket</PaketExePath> |
43 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND '$(PaketBootstrapperStyle)' == 'proj' ">$(PaketToolsPath)paket</PaketExePath> |
44 | | - |
45 | | - <!-- no windows, try mono paket --> |
46 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketRootPath)paket.exe') ">$(PaketRootPath)paket.exe</PaketExePath> |
47 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketToolsPath)paket.exe') ">$(PaketToolsPath)paket.exe</PaketExePath> |
48 | | - |
49 | | - <!-- no windows, try bootstrapper --> |
50 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' AND Exists('$(PaketBootStrapperExeDir)') ">$(PaketBootStrapperExeDir)paket.exe</PaketExePath> |
51 | | - |
52 | | - <!-- no windows, try global native paket --> |
53 | | - <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(OS)' != 'Windows_NT' ">paket</PaketExePath> |
54 | | - |
55 | | - <!-- Paket command --> |
56 | | - <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))</_PaketExeExtension> |
57 | | - <PaketCommand Condition=" '$(PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</PaketCommand> |
58 | | - <PaketCommand Condition=" '$(PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand> |
59 | | - <PaketCommand Condition=" '$(PaketCommand)' == '' ">"$(PaketExePath)"</PaketCommand> |
60 | | - |
61 | | - |
62 | | - <PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand> |
| 31 | + <PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT' ">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand> |
63 | 32 | <PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"</PaketBootStrapperCommand> |
64 | 33 |
|
65 | | - <!-- Disable automagic references for F# dotnet sdk --> |
| 34 | + <!-- Disable automagic references for F# DotNet SDK --> |
66 | 35 | <!-- This will not do anything for other project types --> |
67 | | - <!-- see https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1032-fsharp-in-dotnet-sdk.md --> |
| 36 | + <!-- see https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1002-fsharp-in-dotnet-sdk.md --> |
68 | 37 | <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference> |
69 | 38 | <DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference> |
70 | 39 |
|
71 | 40 | <!-- Disable Paket restore under NCrunch build --> |
72 | 41 | <PaketRestoreDisabled Condition="'$(NCrunch)' == '1'">True</PaketRestoreDisabled> |
73 | 42 |
|
| 43 | + <!-- Disable test for CLI tool completely - overrideable via properties in projects or via environment variables --> |
| 44 | + <PaketDisableCliTest Condition=" '$(PaketDisableCliTest)' == '' ">False</PaketDisableCliTest> |
| 45 | + |
74 | 46 | <PaketIntermediateOutputPath Condition=" '$(PaketIntermediateOutputPath)' == '' ">$(BaseIntermediateOutputPath.TrimEnd('\').TrimEnd('\/'))</PaketIntermediateOutputPath> |
75 | 47 | </PropertyGroup> |
76 | 48 |
|
| 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 --> |
| 51 | + <Target Name="SetPaketCommand" > |
| 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> |
| 58 | + |
| 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> |
| 64 | + </PropertyGroup> |
| 65 | + |
| 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> |
| 73 | + |
| 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> |
| 79 | + |
| 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> |
| 84 | + |
| 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> |
| 90 | + |
| 91 | + <!-- If all else fails, use global path approach. --> |
| 92 | + <PaketExePath Condition=" '$(PaketExePath)' == ''">paket</PaketExePath> |
| 93 | + </PropertyGroup> |
| 94 | + |
| 95 | + <!-- If not using CLI, setup correct execution command. --> |
| 96 | + <PropertyGroup Condition=" '$(_PaketCommand)' == '' "> |
| 97 | + <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))</_PaketExeExtension> |
| 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> |
| 101 | + </PropertyGroup> |
| 102 | + |
| 103 | + <!-- The way to get a property to be available outside the target is to use this task. --> |
| 104 | + <CreateProperty Value="$(_PaketCommand)"> |
| 105 | + <Output TaskParameter="Value" PropertyName="PaketCommand"/> |
| 106 | + </CreateProperty> |
| 107 | + |
| 108 | + </Target> |
| 109 | + |
77 | 110 | <Target Name="PaketBootstrapping" Condition="Exists('$(PaketToolsPath)paket.bootstrapper.proj')"> |
78 | 111 | <MSBuild Projects="$(PaketToolsPath)paket.bootstrapper.proj" Targets="Restore" /> |
79 | 112 | </Target> |
80 | 113 |
|
81 | 114 | <!-- Official workaround for https://docs.microsoft.com/en-us/visualstudio/msbuild/getfilehash-task?view=vs-2019 --> |
82 | 115 | <UsingTask TaskName="Microsoft.Build.Tasks.GetFileHash" AssemblyName="Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(DetectedMSBuildVersion)' < '16.0.360' " /> |
83 | 116 | <UsingTask TaskName="Microsoft.Build.Tasks.VerifyFileHash" AssemblyName="Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(DetectedMSBuildVersion)' < '16.0.360' " /> |
84 | | - <Target Name="PaketRestore" Condition="'$(PaketRestoreDisabled)' != 'True'" BeforeTargets="_GenerateDotnetCliToolReferenceSpecs;_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" DependsOnTargets="PaketBootstrapping"> |
| 117 | + <Target Name="PaketRestore" Condition="'$(PaketRestoreDisabled)' != 'True'" BeforeTargets="_GenerateDotnetCliToolReferenceSpecs;_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" DependsOnTargets="SetPaketCommand;PaketBootstrapping"> |
85 | 118 |
|
86 | 119 | <!-- Step 1 Check if lockfile is properly restored (if the hash of the lockfile and the cache-file match) --> |
87 | 120 | <PropertyGroup> |
|
103 | 136 | <!-- Parse our simple 'paket.restore.cached' json ...--> |
104 | 137 | <PaketRestoreCachedSplitObject Include="$([System.Text.RegularExpressions.Regex]::Split(`$(PaketRestoreCachedContents)`, `{|}|,`))"></PaketRestoreCachedSplitObject> |
105 | 138 | <!-- Keep Key, Value ItemGroup--> |
106 | | - <PaketRestoreCachedKeyValue Include="@(PaketRestoreCachedSplitObject)" |
| 139 | + <PaketRestoreCachedKeyValue Include="@(PaketRestoreCachedSplitObject)" |
107 | 140 | Condition=" $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`).Length) > 1 "> |
108 | 141 | <Key>$([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[0].Replace(`"`, ``).Replace(` `, ``))</Key> |
109 | 142 | <Value>$([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[1].Replace(`"`, ``).Replace(` `, ``))</Value> |
|
116 | 149 | </PropertyGroup> |
117 | 150 |
|
118 | 151 | <PropertyGroup Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' "> |
119 | | - <!-- If the restire file doesn't exist we need to restore, otherwise only if hashes don't match --> |
| 152 | + <!-- If the restore file doesn't exist we need to restore, otherwise only if hashes don't match --> |
120 | 153 | <PaketRestoreRequired>true</PaketRestoreRequired> |
121 | 154 | <PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(ProjectsRestoredHash)' ">false</PaketRestoreRequired> |
122 | 155 | <PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired> |
|
136 | 169 | <Exec Command='$(PaketBootStrapperCommand)' Condition=" '$(PaketBootstrapperStyle)' == 'classic' AND Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" /> |
137 | 170 | <Error Text="Stop build because of PAKET_ERROR_ON_MSBUILD_EXEC and we need a full restore (hashes don't match)" Condition=" '$(PAKET_ERROR_ON_MSBUILD_EXEC)' == 'true' AND '$(PaketRestoreRequired)' == 'true' AND '$(PaketDisableGlobalRestore)' != 'true'" /> |
138 | 171 | <Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(PaketDisableGlobalRestore)' != 'true' " ContinueOnError="false" /> |
139 | | - |
| 172 | + |
140 | 173 | <!-- Step 2 Detect project specific changes --> |
141 | 174 | <ItemGroup> |
142 | 175 | <MyTargetFrameworks Condition="'$(TargetFramework)' != '' " Include="$(TargetFramework)"></MyTargetFrameworks> |
|
203 | 236 | <PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName> |
204 | 237 | <PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion> |
205 | 238 | <AllPrivateAssets>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])</AllPrivateAssets> |
206 | | - <CopyLocal Condition="'$(Splits)' == '6'">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])</CopyLocal> |
| 239 | + <CopyLocal Condition="'%(PaketReferencesFileLinesInfo.Splits)' == '6'">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])</CopyLocal> |
207 | 240 | </PaketReferencesFileLinesInfo> |
208 | 241 | <PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)"> |
209 | 242 | <Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version> |
|
246 | 279 | </PropertyGroup> |
247 | 280 | </Target> |
248 | 281 |
|
249 | | - <Target Name="PaketOverrideNuspec" AfterTargets="GenerateNuspec" Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).references')" > |
| 282 | + <Target Name="PaketOverrideNuspec" DependsOnTargets="SetPaketCommand" AfterTargets="GenerateNuspec" Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).references')" > |
250 | 283 | <ItemGroup> |
251 | 284 | <_NuspecFilesNewLocation Include="$(PaketIntermediateOutputPath)\$(Configuration)\*.nuspec"/> |
252 | 285 | <MSBuildMajorVersion Include="$(DetectedMSBuildVersion.Replace(`-`, `.`).Split(`.`)[0])" /> |
|
300 | 333 | DevelopmentDependency="$(DevelopmentDependency)" |
301 | 334 | BuildOutputInPackage="@(_BuildOutputInPackage)" |
302 | 335 | TargetPathsToSymbols="@(_TargetPathsToSymbols)" |
303 | | - SymbolPackageFormat="symbols.nupkg" |
| 336 | + SymbolPackageFormat="$(SymbolPackageFormat)" |
304 | 337 | TargetFrameworks="@(_TargetFrameworks)" |
305 | 338 | AssemblyName="$(AssemblyName)" |
306 | 339 | PackageOutputPath="$(PackageOutputAbsolutePath)" |
|
347 | 380 | DevelopmentDependency="$(DevelopmentDependency)" |
348 | 381 | BuildOutputInPackage="@(_BuildOutputInPackage)" |
349 | 382 | TargetPathsToSymbols="@(_TargetPathsToSymbols)" |
350 | | - SymbolPackageFormat="symbols.nupkg" |
| 383 | + SymbolPackageFormat="$(SymbolPackageFormat)" |
351 | 384 | TargetFrameworks="@(_TargetFrameworks)" |
352 | 385 | AssemblyName="$(AssemblyName)" |
353 | 386 | PackageOutputPath="$(PackageOutputAbsolutePath)" |
|
0 commit comments