Paket.Restore.targets 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  2. <!-- Prevent dotnet template engine to parse this file -->
  3. <!--/-:cnd:noEmit-->
  4. <PropertyGroup>
  5. <!-- make MSBuild track this file for incremental builds. -->
  6. <!-- ref https://blogs.msdn.microsoft.com/msbuild/2005/09/26/how-to-ensure-changes-to-a-custom-target-file-prompt-a-rebuild/ -->
  7. <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
  8. <DetectedMSBuildVersion>$(MSBuildVersion)</DetectedMSBuildVersion>
  9. <DetectedMSBuildVersion Condition="'$(MSBuildVersion)' == ''">15.0.0</DetectedMSBuildVersion>
  10. <MSBuildSupportsHashing>false</MSBuildSupportsHashing>
  11. <MSBuildSupportsHashing Condition=" '$(DetectedMSBuildVersion)' &gt; '15.8.0' ">true</MSBuildSupportsHashing>
  12. <!-- Mark that this target file has been loaded. -->
  13. <IsPaketRestoreTargetsFileLoaded>true</IsPaketRestoreTargetsFileLoaded>
  14. <PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
  15. <PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
  16. <PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile>
  17. <PaketLockFilePath>$(PaketRootPath)paket.lock</PaketLockFilePath>
  18. <PaketBootstrapperStyle>classic</PaketBootstrapperStyle>
  19. <PaketBootstrapperStyle Condition="Exists('$(PaketToolsPath)paket.bootstrapper.proj')">proj</PaketBootstrapperStyle>
  20. <PaketExeImage>assembly</PaketExeImage>
  21. <PaketExeImage Condition=" '$(PaketBootstrapperStyle)' == 'proj' ">native</PaketExeImage>
  22. <MonoPath Condition="'$(MonoPath)' == '' AND Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
  23. <MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
  24. <!-- PaketBootStrapper -->
  25. <PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
  26. <PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
  27. <PaketBootStrapperExeDir Condition=" Exists('$(PaketBootStrapperExePath)') " >$([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\</PaketBootStrapperExeDir>
  28. <PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT' ">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
  29. <PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
  30. <!-- Disable automagic references for F# DotNet SDK -->
  31. <!-- This will not do anything for other project types -->
  32. <!-- see https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1002-fsharp-in-dotnet-sdk.md -->
  33. <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
  34. <DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
  35. <!-- Disable Paket restore under NCrunch build -->
  36. <PaketRestoreDisabled Condition="'$(NCrunch)' == '1'">True</PaketRestoreDisabled>
  37. <!-- Disable test for CLI tool completely - overrideable via properties in projects or via environment variables -->
  38. <PaketDisableCliTest Condition=" '$(PaketDisableCliTest)' == '' ">False</PaketDisableCliTest>
  39. <PaketIntermediateOutputPath Condition=" '$(PaketIntermediateOutputPath)' == '' ">$(BaseIntermediateOutputPath.TrimEnd('\').TrimEnd('\/'))</PaketIntermediateOutputPath>
  40. </PropertyGroup>
  41. <!-- Resolve how paket should be called -->
  42. <!-- 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 -->
  43. <Target Name="SetPaketCommand" >
  44. <!-- Test if paket is available in the standard locations. If so, that takes priority. Case 1/2 - non-windows specific -->
  45. <PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
  46. <!-- no windows, try native paket as default, root => tool -->
  47. <PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket') ">$(PaketRootPath)paket</PaketExePath>
  48. <PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketToolsPath)paket') ">$(PaketToolsPath)paket</PaketExePath>
  49. </PropertyGroup>
  50. <!-- Test if paket is available in the standard locations. If so, that takes priority. Case 2/2 - same across platforms -->
  51. <PropertyGroup>
  52. <!-- root => tool -->
  53. <PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe') ">$(PaketRootPath)paket.exe</PaketExePath>
  54. <PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketToolsPath)paket.exe') ">$(PaketToolsPath)paket.exe</PaketExePath>
  55. </PropertyGroup>
  56. <!-- If paket hasn't be found in standard locations, test for CLI tool usage. -->
  57. <!-- First test: Is CLI configured to be used in "dotnet-tools.json"? - can result in a false negative; only a positive outcome is reliable. -->
  58. <PropertyGroup Condition=" '$(PaketExePath)' == '' ">
  59. <_DotnetToolsJson Condition="Exists('$(PaketRootPath)/.config/dotnet-tools.json')">$([System.IO.File]::ReadAllText("$(PaketRootPath)/.config/dotnet-tools.json"))</_DotnetToolsJson>
  60. <_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$(_DotnetToolsJson.Contains('"paket"'))</_ConfigContainsPaket>
  61. <_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false</_ConfigContainsPaket>
  62. </PropertyGroup>
  63. <!-- 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. -->
  64. <!-- 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. -->
  65. <Exec Condition=" '$(PaketExePath)' == '' AND !$(PaketDisableCliTest) AND !$(_ConfigContainsPaket)" Command="dotnet paket --version" IgnoreExitCode="true" StandardOutputImportance="low" StandardErrorImportance="low" >
  66. <Output TaskParameter="ExitCode" PropertyName="LocalPaketToolExitCode" />
  67. </Exec>
  68. <!-- If paket is installed as CLI use that. Again, only if paket haven't already been found in standard locations. -->
  69. <PropertyGroup Condition=" '$(PaketExePath)' == '' AND ($(_ConfigContainsPaket) OR '$(LocalPaketToolExitCode)' == '0') ">
  70. <_PaketCommand>dotnet paket</_PaketCommand>
  71. </PropertyGroup>
  72. <!-- If neither local files nor CLI tool can be found, final attempt is searching for boostrapper config before falling back to global path variable. -->
  73. <PropertyGroup Condition=" '$(PaketExePath)' == '' AND '$(_PaketCommand)' == '' ">
  74. <!-- Test for bootstrapper setup -->
  75. <PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(PaketBootstrapperStyle)' == 'proj' ">$(PaketToolsPath)paket</PaketExePath>
  76. <PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketBootStrapperExeDir)') ">$(PaketBootStrapperExeDir)paket</PaketExePath>
  77. <!-- If all else fails, use global path approach. -->
  78. <PaketExePath Condition=" '$(PaketExePath)' == ''">paket</PaketExePath>
  79. </PropertyGroup>
  80. <!-- If not using CLI, setup correct execution command. -->
  81. <PropertyGroup Condition=" '$(_PaketCommand)' == '' ">
  82. <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))</_PaketExeExtension>
  83. <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</_PaketCommand>
  84. <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</_PaketCommand>
  85. <_PaketCommand Condition=" '$(_PaketCommand)' == '' ">"$(PaketExePath)"</_PaketCommand>
  86. </PropertyGroup>
  87. <!-- The way to get a property to be available outside the target is to use this task. -->
  88. <CreateProperty Value="$(_PaketCommand)">
  89. <Output TaskParameter="Value" PropertyName="PaketCommand"/>
  90. </CreateProperty>
  91. </Target>
  92. <Target Name="PaketBootstrapping" Condition="Exists('$(PaketToolsPath)paket.bootstrapper.proj')">
  93. <MSBuild Projects="$(PaketToolsPath)paket.bootstrapper.proj" Targets="Restore" />
  94. </Target>
  95. <!-- Official workaround for https://docs.microsoft.com/en-us/visualstudio/msbuild/getfilehash-task?view=vs-2019 -->
  96. <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)' &lt; '16.0.360' " />
  97. <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)' &lt; '16.0.360' " />
  98. <Target Name="PaketRestore" Condition="'$(PaketRestoreDisabled)' != 'True'" BeforeTargets="_GenerateDotnetCliToolReferenceSpecs;_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" DependsOnTargets="SetPaketCommand;PaketBootstrapping">
  99. <!-- Step 1 Check if lockfile is properly restored (if the hash of the lockfile and the cache-file match) -->
  100. <PropertyGroup>
  101. <PaketRestoreRequired>true</PaketRestoreRequired>
  102. <NoWarn>$(NoWarn);NU1603;NU1604;NU1605;NU1608</NoWarn>
  103. <CacheFilesExist>false</CacheFilesExist>
  104. <CacheFilesExist Condition=" Exists('$(PaketRestoreCacheFile)') And Exists('$(PaketLockFilePath)') ">true</CacheFilesExist>
  105. </PropertyGroup>
  106. <!-- Read the hash of the lockfile -->
  107. <GetFileHash Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' " Files="$(PaketLockFilePath)" Algorithm="SHA256" HashEncoding="hex" >
  108. <Output TaskParameter="Hash" PropertyName="PaketRestoreLockFileHash" />
  109. </GetFileHash>
  110. <!-- Read the hash of the cache, which is json, but a very simple key value object -->
  111. <PropertyGroup Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' ">
  112. <PaketRestoreCachedContents>$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedContents>
  113. </PropertyGroup>
  114. <ItemGroup Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' ">
  115. <!-- Parse our simple 'paket.restore.cached' json ...-->
  116. <PaketRestoreCachedSplitObject Include="$([System.Text.RegularExpressions.Regex]::Split(`$(PaketRestoreCachedContents)`, `{|}|,`))"></PaketRestoreCachedSplitObject>
  117. <!-- Keep Key, Value ItemGroup-->
  118. <PaketRestoreCachedKeyValue Include="@(PaketRestoreCachedSplitObject)"
  119. Condition=" $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `&quot;: &quot;`).Length) &gt; 1 ">
  120. <Key>$([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[0].Replace(`"`, ``).Replace(` `, ``))</Key>
  121. <Value>$([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[1].Replace(`"`, ``).Replace(` `, ``))</Value>
  122. </PaketRestoreCachedKeyValue>
  123. </ItemGroup>
  124. <PropertyGroup Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' ">
  125. <!-- Retrieve the hashes we are interested in -->
  126. <PackagesDownloadedHash Condition=" '%(PaketRestoreCachedKeyValue.Key)' == 'packagesDownloadedHash' ">%(PaketRestoreCachedKeyValue.Value)</PackagesDownloadedHash>
  127. <ProjectsRestoredHash Condition=" '%(PaketRestoreCachedKeyValue.Key)' == 'projectsRestoredHash' ">%(PaketRestoreCachedKeyValue.Value)</ProjectsRestoredHash>
  128. </PropertyGroup>
  129. <PropertyGroup Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' ">
  130. <!-- If the restore file doesn't exist we need to restore, otherwise only if hashes don't match -->
  131. <PaketRestoreRequired>true</PaketRestoreRequired>
  132. <PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(ProjectsRestoredHash)' ">false</PaketRestoreRequired>
  133. <PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
  134. </PropertyGroup>
  135. <!--
  136. This value should match the version in the props generated by paket
  137. If they differ, this means we need to do a restore in order to ensure correct dependencies
  138. -->
  139. <PropertyGroup Condition="'$(PaketPropsVersion)' != '5.185.3' ">
  140. <PaketRestoreRequired>true</PaketRestoreRequired>
  141. </PropertyGroup>
  142. <!-- Do a global restore if required -->
  143. <Warning Text="This version of MSBuild (we assume '$(DetectedMSBuildVersion)' or older) doesn't support GetFileHash, so paket fast restore is disabled." Condition=" '$(MSBuildSupportsHashing)' != 'true' " />
  144. <Error Text="Stop build because of PAKET_ERROR_ON_MSBUILD_EXEC and we always call the bootstrapper" Condition=" '$(PAKET_ERROR_ON_MSBUILD_EXEC)' == 'true' AND '$(PaketBootstrapperStyle)' == 'classic' AND Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" />
  145. <Exec Command='$(PaketBootStrapperCommand)' Condition=" '$(PaketBootstrapperStyle)' == 'classic' AND Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
  146. <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'" />
  147. <Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(PaketDisableGlobalRestore)' != 'true' " ContinueOnError="false" />
  148. <!-- Step 2 Detect project specific changes -->
  149. <ItemGroup>
  150. <MyTargetFrameworks Condition="'$(TargetFramework)' != '' " Include="$(TargetFramework)"></MyTargetFrameworks>
  151. <!-- Don't include all frameworks when msbuild explicitly asks for a single one -->
  152. <MyTargetFrameworks Condition="'$(TargetFrameworks)' != '' AND '$(TargetFramework)' == '' " Include="$(TargetFrameworks)"></MyTargetFrameworks>
  153. <PaketResolvedFilePaths Include="@(MyTargetFrameworks -> '$(PaketIntermediateOutputPath)\$(MSBuildProjectFile).%(Identity).paket.resolved')"></PaketResolvedFilePaths>
  154. </ItemGroup>
  155. <PropertyGroup>
  156. <PaketReferencesCachedFilePath>$(PaketIntermediateOutputPath)\$(MSBuildProjectFile).paket.references.cached</PaketReferencesCachedFilePath>
  157. <!-- MyProject.fsproj.paket.references has the highest precedence -->
  158. <PaketOriginalReferencesFilePath>$(MSBuildProjectFullPath).paket.references</PaketOriginalReferencesFilePath>
  159. <!-- MyProject.paket.references -->
  160. <PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketOriginalReferencesFilePath>
  161. <!-- paket.references -->
  162. <PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\paket.references</PaketOriginalReferencesFilePath>
  163. <DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
  164. <DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
  165. <PaketRestoreRequired>true</PaketRestoreRequired>
  166. <PaketRestoreRequiredReason>references-file-or-cache-not-found</PaketRestoreRequiredReason>
  167. </PropertyGroup>
  168. <!-- Step 2 a Detect changes in references file -->
  169. <PropertyGroup Condition="Exists('$(PaketOriginalReferencesFilePath)') AND Exists('$(PaketReferencesCachedFilePath)') ">
  170. <PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketReferencesCachedFilePath)'))</PaketRestoreCachedHash>
  171. <PaketRestoreReferencesFileHash>$([System.IO.File]::ReadAllText('$(PaketOriginalReferencesFilePath)'))</PaketRestoreReferencesFileHash>
  172. <PaketRestoreRequiredReason>references-file</PaketRestoreRequiredReason>
  173. <PaketRestoreRequired Condition=" '$(PaketRestoreReferencesFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired>
  174. </PropertyGroup>
  175. <PropertyGroup Condition="!Exists('$(PaketOriginalReferencesFilePath)') AND !Exists('$(PaketReferencesCachedFilePath)') ">
  176. <!-- If both don't exist there is nothing to do. -->
  177. <PaketRestoreRequired>false</PaketRestoreRequired>
  178. </PropertyGroup>
  179. <!-- Step 2 b detect relevant changes in project file (new targetframework) -->
  180. <PropertyGroup Condition=" '$(DoAllResolvedFilesExist)' != 'true' ">
  181. <PaketRestoreRequired>true</PaketRestoreRequired>
  182. <PaketRestoreRequiredReason>target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths)</PaketRestoreRequiredReason>
  183. </PropertyGroup>
  184. <!-- Step 3 Restore project specific stuff if required -->
  185. <Message Condition=" '$(PaketRestoreRequired)' == 'true' " Importance="low" Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" />
  186. <Error Text="Stop build because of PAKET_ERROR_ON_MSBUILD_EXEC and we detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)'" Condition=" '$(PAKET_ERROR_ON_MSBUILD_EXEC)' == 'true' AND '$(PaketRestoreRequired)' == 'true' " />
  187. <Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" --output-path "$(PaketIntermediateOutputPath)" --target-framework "$(TargetFrameworks)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' == '' " ContinueOnError="false" />
  188. <Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" --output-path "$(PaketIntermediateOutputPath)" --target-framework "$(TargetFramework)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' != '' " ContinueOnError="false" />
  189. <!-- This shouldn't actually happen, but just to be sure. -->
  190. <PropertyGroup>
  191. <DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
  192. <DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
  193. </PropertyGroup>
  194. <Error Condition=" '$(DoAllResolvedFilesExist)' != 'true' AND '$(ResolveNuGetPackages)' != 'False' " Text="One Paket file '@(PaketResolvedFilePaths)' is missing while restoring $(MSBuildProjectFile). Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />
  195. <!-- Step 4 forward all msbuild properties (PackageReference, DotNetCliToolReference) to msbuild -->
  196. <ReadLinesFromFile Condition="($(DesignTimeBuild) != true OR '$(PaketPropsLoaded)' != 'true') AND '@(PaketResolvedFilePaths)' != ''" File="%(PaketResolvedFilePaths.Identity)" >
  197. <Output TaskParameter="Lines" ItemName="PaketReferencesFileLines"/>
  198. </ReadLinesFromFile>
  199. <ItemGroup Condition="($(DesignTimeBuild) != true OR '$(PaketPropsLoaded)' != 'true') AND '@(PaketReferencesFileLines)' != '' " >
  200. <PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
  201. <Splits>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length)</Splits>
  202. <PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
  203. <PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
  204. <AllPrivateAssets>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])</AllPrivateAssets>
  205. <CopyLocal Condition="'%(PaketReferencesFileLinesInfo.Splits)' == '6'">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])</CopyLocal>
  206. </PaketReferencesFileLinesInfo>
  207. <PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
  208. <Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
  209. <PrivateAssets Condition=" ('%(PaketReferencesFileLinesInfo.AllPrivateAssets)' == 'true') Or ('$(PackAsTool)' == 'true') ">All</PrivateAssets>
  210. <ExcludeAssets Condition=" '%(PaketReferencesFileLinesInfo.Splits)' == '6' And %(PaketReferencesFileLinesInfo.CopyLocal) == 'false'">runtime</ExcludeAssets>
  211. <ExcludeAssets Condition=" '%(PaketReferencesFileLinesInfo.Splits)' != '6' And %(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'">runtime</ExcludeAssets>
  212. <Publish Condition=" '$(PackAsTool)' == 'true' ">true</Publish>
  213. <AllowExplicitVersion>true</AllowExplicitVersion>
  214. </PackageReference>
  215. </ItemGroup>
  216. <PropertyGroup>
  217. <PaketCliToolFilePath>$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).paket.clitools</PaketCliToolFilePath>
  218. </PropertyGroup>
  219. <ReadLinesFromFile File="$(PaketCliToolFilePath)" >
  220. <Output TaskParameter="Lines" ItemName="PaketCliToolFileLines"/>
  221. </ReadLinesFromFile>
  222. <ItemGroup Condition=" '@(PaketCliToolFileLines)' != '' " >
  223. <PaketCliToolFileLinesInfo Include="@(PaketCliToolFileLines)" >
  224. <PackageName>$([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[0])</PackageName>
  225. <PackageVersion>$([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[1])</PackageVersion>
  226. </PaketCliToolFileLinesInfo>
  227. <DotNetCliToolReference Include="%(PaketCliToolFileLinesInfo.PackageName)">
  228. <Version>%(PaketCliToolFileLinesInfo.PackageVersion)</Version>
  229. </DotNetCliToolReference>
  230. </ItemGroup>
  231. <!-- Disabled for now until we know what to do with runtime deps - https://github.com/fsprojects/Paket/issues/2964
  232. <PropertyGroup>
  233. <RestoreConfigFile>$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).NuGet.Config</RestoreConfigFile>
  234. </PropertyGroup> -->
  235. </Target>
  236. <Target Name="PaketDisableDirectPack" AfterTargets="_IntermediatePack" BeforeTargets="GenerateNuspec" Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).references')" >
  237. <PropertyGroup>
  238. <ContinuePackingAfterGeneratingNuspec>false</ContinuePackingAfterGeneratingNuspec>
  239. </PropertyGroup>
  240. </Target>
  241. <Target Name="PaketOverrideNuspec" DependsOnTargets="SetPaketCommand" AfterTargets="GenerateNuspec" Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).references')" >
  242. <ItemGroup>
  243. <_NuspecFilesNewLocation Include="$(PaketIntermediateOutputPath)\$(Configuration)\*.nuspec"/>
  244. <MSBuildMajorVersion Include="$(DetectedMSBuildVersion.Replace(`-`, `.`).Split(`.`)[0])" />
  245. <MSBuildMinorVersion Include="$(DetectedMSBuildVersion.Replace(`-`, `.`).Split(`.`)[1])" />
  246. </ItemGroup>
  247. <PropertyGroup>
  248. <PaketProjectFile>$(MSBuildProjectDirectory)/$(MSBuildProjectFile)</PaketProjectFile>
  249. <ContinuePackingAfterGeneratingNuspec>true</ContinuePackingAfterGeneratingNuspec>
  250. <UseMSBuild16_0_Pack>false</UseMSBuild16_0_Pack>
  251. <UseMSBuild16_0_Pack Condition=" '@(MSBuildMajorVersion)' >= '16' ">true</UseMSBuild16_0_Pack>
  252. <UseMSBuild15_9_Pack>false</UseMSBuild15_9_Pack>
  253. <UseMSBuild15_9_Pack Condition=" '@(MSBuildMajorVersion)' == '15' AND '@(MSBuildMinorVersion)' > '8' ">true</UseMSBuild15_9_Pack>
  254. <UseMSBuild15_8_Pack>false</UseMSBuild15_8_Pack>
  255. <UseMSBuild15_8_Pack Condition=" '$(NuGetToolVersion)' != '4.0.0' AND (! $(UseMSBuild15_9_Pack)) AND (! $(UseMSBuild16_0_Pack)) ">true</UseMSBuild15_8_Pack>
  256. <UseNuGet4_Pack>false</UseNuGet4_Pack>
  257. <UseNuGet4_Pack Condition=" (! $(UseMSBuild15_8_Pack)) AND (! $(UseMSBuild15_9_Pack)) AND (! $(UseMSBuild16_0_Pack)) ">true</UseNuGet4_Pack>
  258. <AdjustedNuspecOutputPath>$(PaketIntermediateOutputPath)\$(Configuration)</AdjustedNuspecOutputPath>
  259. <AdjustedNuspecOutputPath Condition="@(_NuspecFilesNewLocation) == ''">$(PaketIntermediateOutputPath)</AdjustedNuspecOutputPath>
  260. </PropertyGroup>
  261. <ItemGroup>
  262. <_NuspecFiles Include="$(AdjustedNuspecOutputPath)\*.$(PackageVersion.Split(`+`)[0]).nuspec"/>
  263. </ItemGroup>
  264. <Error Text="Error Because of PAKET_ERROR_ON_MSBUILD_EXEC (not calling fix-nuspecs)" Condition=" '$(PAKET_ERROR_ON_MSBUILD_EXEC)' == 'true' " />
  265. <Exec Condition="@(_NuspecFiles) != ''" Command='$(PaketCommand) fix-nuspecs files "@(_NuspecFiles)" project-file "$(PaketProjectFile)" ' />
  266. <Error Condition="@(_NuspecFiles) == ''" Text='Could not find nuspec files in "$(AdjustedNuspecOutputPath)" (Version: "$(PackageVersion)"), therefore we cannot call "paket fix-nuspecs" and have to error out!' />
  267. <ConvertToAbsolutePath Condition="@(_NuspecFiles) != ''" Paths="@(_NuspecFiles)">
  268. <Output TaskParameter="AbsolutePaths" PropertyName="NuspecFileAbsolutePath" />
  269. </ConvertToAbsolutePath>
  270. <!-- Call Pack -->
  271. <PackTask Condition="$(UseMSBuild16_0_Pack)"
  272. PackItem="$(PackProjectInputFile)"
  273. PackageFiles="@(_PackageFiles)"
  274. PackageFilesToExclude="@(_PackageFilesToExclude)"
  275. PackageVersion="$(PackageVersion)"
  276. PackageId="$(PackageId)"
  277. Title="$(Title)"
  278. Authors="$(Authors)"
  279. Description="$(Description)"
  280. Copyright="$(Copyright)"
  281. RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
  282. LicenseUrl="$(PackageLicenseUrl)"
  283. ProjectUrl="$(PackageProjectUrl)"
  284. IconUrl="$(PackageIconUrl)"
  285. ReleaseNotes="$(PackageReleaseNotes)"
  286. Tags="$(PackageTags)"
  287. DevelopmentDependency="$(DevelopmentDependency)"
  288. BuildOutputInPackage="@(_BuildOutputInPackage)"
  289. TargetPathsToSymbols="@(_TargetPathsToSymbols)"
  290. SymbolPackageFormat="$(SymbolPackageFormat)"
  291. TargetFrameworks="@(_TargetFrameworks)"
  292. AssemblyName="$(AssemblyName)"
  293. PackageOutputPath="$(PackageOutputAbsolutePath)"
  294. IncludeSymbols="$(IncludeSymbols)"
  295. IncludeSource="$(IncludeSource)"
  296. PackageTypes="$(PackageType)"
  297. IsTool="$(IsTool)"
  298. RepositoryUrl="$(RepositoryUrl)"
  299. RepositoryType="$(RepositoryType)"
  300. SourceFiles="@(_SourceFiles->Distinct())"
  301. NoPackageAnalysis="$(NoPackageAnalysis)"
  302. MinClientVersion="$(MinClientVersion)"
  303. Serviceable="$(Serviceable)"
  304. FrameworkAssemblyReferences="@(_FrameworkAssemblyReferences)"
  305. ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
  306. NuspecOutputPath="$(AdjustedNuspecOutputPath)"
  307. IncludeBuildOutput="$(IncludeBuildOutput)"
  308. BuildOutputFolders="$(BuildOutputTargetFolder)"
  309. ContentTargetFolders="$(ContentTargetFolders)"
  310. RestoreOutputPath="$(RestoreOutputAbsolutePath)"
  311. NuspecFile="$(NuspecFileAbsolutePath)"
  312. NuspecBasePath="$(NuspecBasePath)"
  313. NuspecProperties="$(NuspecProperties)"
  314. PackageLicenseFile="$(PackageLicenseFile)"
  315. PackageLicenseExpression="$(PackageLicenseExpression)"
  316. PackageLicenseExpressionVersion="$(PackageLicenseExpressionVersion)" />
  317. <PackTask Condition="$(UseMSBuild15_9_Pack)"
  318. PackItem="$(PackProjectInputFile)"
  319. PackageFiles="@(_PackageFiles)"
  320. PackageFilesToExclude="@(_PackageFilesToExclude)"
  321. PackageVersion="$(PackageVersion)"
  322. PackageId="$(PackageId)"
  323. Title="$(Title)"
  324. Authors="$(Authors)"
  325. Description="$(Description)"
  326. Copyright="$(Copyright)"
  327. RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
  328. LicenseUrl="$(PackageLicenseUrl)"
  329. ProjectUrl="$(PackageProjectUrl)"
  330. IconUrl="$(PackageIconUrl)"
  331. ReleaseNotes="$(PackageReleaseNotes)"
  332. Tags="$(PackageTags)"
  333. DevelopmentDependency="$(DevelopmentDependency)"
  334. BuildOutputInPackage="@(_BuildOutputInPackage)"
  335. TargetPathsToSymbols="@(_TargetPathsToSymbols)"
  336. SymbolPackageFormat="$(SymbolPackageFormat)"
  337. TargetFrameworks="@(_TargetFrameworks)"
  338. AssemblyName="$(AssemblyName)"
  339. PackageOutputPath="$(PackageOutputAbsolutePath)"
  340. IncludeSymbols="$(IncludeSymbols)"
  341. IncludeSource="$(IncludeSource)"
  342. PackageTypes="$(PackageType)"
  343. IsTool="$(IsTool)"
  344. RepositoryUrl="$(RepositoryUrl)"
  345. RepositoryType="$(RepositoryType)"
  346. SourceFiles="@(_SourceFiles->Distinct())"
  347. NoPackageAnalysis="$(NoPackageAnalysis)"
  348. MinClientVersion="$(MinClientVersion)"
  349. Serviceable="$(Serviceable)"
  350. FrameworkAssemblyReferences="@(_FrameworkAssemblyReferences)"
  351. ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
  352. NuspecOutputPath="$(AdjustedNuspecOutputPath)"
  353. IncludeBuildOutput="$(IncludeBuildOutput)"
  354. BuildOutputFolder="$(BuildOutputTargetFolder)"
  355. ContentTargetFolders="$(ContentTargetFolders)"
  356. RestoreOutputPath="$(RestoreOutputAbsolutePath)"
  357. NuspecFile="$(NuspecFileAbsolutePath)"
  358. NuspecBasePath="$(NuspecBasePath)"
  359. NuspecProperties="$(NuspecProperties)"/>
  360. <PackTask Condition="$(UseMSBuild15_8_Pack)"
  361. PackItem="$(PackProjectInputFile)"
  362. PackageFiles="@(_PackageFiles)"
  363. PackageFilesToExclude="@(_PackageFilesToExclude)"
  364. PackageVersion="$(PackageVersion)"
  365. PackageId="$(PackageId)"
  366. Title="$(Title)"
  367. Authors="$(Authors)"
  368. Description="$(Description)"
  369. Copyright="$(Copyright)"
  370. RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
  371. LicenseUrl="$(PackageLicenseUrl)"
  372. ProjectUrl="$(PackageProjectUrl)"
  373. IconUrl="$(PackageIconUrl)"
  374. ReleaseNotes="$(PackageReleaseNotes)"
  375. Tags="$(PackageTags)"
  376. DevelopmentDependency="$(DevelopmentDependency)"
  377. BuildOutputInPackage="@(_BuildOutputInPackage)"
  378. TargetPathsToSymbols="@(_TargetPathsToSymbols)"
  379. TargetFrameworks="@(_TargetFrameworks)"
  380. AssemblyName="$(AssemblyName)"
  381. PackageOutputPath="$(PackageOutputAbsolutePath)"
  382. IncludeSymbols="$(IncludeSymbols)"
  383. IncludeSource="$(IncludeSource)"
  384. PackageTypes="$(PackageType)"
  385. IsTool="$(IsTool)"
  386. RepositoryUrl="$(RepositoryUrl)"
  387. RepositoryType="$(RepositoryType)"
  388. SourceFiles="@(_SourceFiles->Distinct())"
  389. NoPackageAnalysis="$(NoPackageAnalysis)"
  390. MinClientVersion="$(MinClientVersion)"
  391. Serviceable="$(Serviceable)"
  392. FrameworkAssemblyReferences="@(_FrameworkAssemblyReferences)"
  393. ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
  394. NuspecOutputPath="$(AdjustedNuspecOutputPath)"
  395. IncludeBuildOutput="$(IncludeBuildOutput)"
  396. BuildOutputFolder="$(BuildOutputTargetFolder)"
  397. ContentTargetFolders="$(ContentTargetFolders)"
  398. RestoreOutputPath="$(RestoreOutputAbsolutePath)"
  399. NuspecFile="$(NuspecFileAbsolutePath)"
  400. NuspecBasePath="$(NuspecBasePath)"
  401. NuspecProperties="$(NuspecProperties)"/>
  402. <PackTask Condition="$(UseNuGet4_Pack)"
  403. PackItem="$(PackProjectInputFile)"
  404. PackageFiles="@(_PackageFiles)"
  405. PackageFilesToExclude="@(_PackageFilesToExclude)"
  406. PackageVersion="$(PackageVersion)"
  407. PackageId="$(PackageId)"
  408. Title="$(Title)"
  409. Authors="$(Authors)"
  410. Description="$(Description)"
  411. Copyright="$(Copyright)"
  412. RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
  413. LicenseUrl="$(PackageLicenseUrl)"
  414. ProjectUrl="$(PackageProjectUrl)"
  415. IconUrl="$(PackageIconUrl)"
  416. ReleaseNotes="$(PackageReleaseNotes)"
  417. Tags="$(PackageTags)"
  418. TargetPathsToAssemblies="@(_TargetPathsToAssemblies->'%(FinalOutputPath)')"
  419. TargetPathsToSymbols="@(_TargetPathsToSymbols)"
  420. TargetFrameworks="@(_TargetFrameworks)"
  421. AssemblyName="$(AssemblyName)"
  422. PackageOutputPath="$(PackageOutputAbsolutePath)"
  423. IncludeSymbols="$(IncludeSymbols)"
  424. IncludeSource="$(IncludeSource)"
  425. PackageTypes="$(PackageType)"
  426. IsTool="$(IsTool)"
  427. RepositoryUrl="$(RepositoryUrl)"
  428. RepositoryType="$(RepositoryType)"
  429. SourceFiles="@(_SourceFiles->Distinct())"
  430. NoPackageAnalysis="$(NoPackageAnalysis)"
  431. MinClientVersion="$(MinClientVersion)"
  432. Serviceable="$(Serviceable)"
  433. AssemblyReferences="@(_References)"
  434. ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
  435. NuspecOutputPath="$(AdjustedNuspecOutputPath)"
  436. IncludeBuildOutput="$(IncludeBuildOutput)"
  437. BuildOutputFolder="$(BuildOutputTargetFolder)"
  438. ContentTargetFolders="$(ContentTargetFolders)"
  439. RestoreOutputPath="$(RestoreOutputAbsolutePath)"
  440. NuspecFile="$(NuspecFileAbsolutePath)"
  441. NuspecBasePath="$(NuspecBasePath)"
  442. NuspecProperties="$(NuspecProperties)"/>
  443. </Target>
  444. <!--/+:cnd:noEmit-->
  445. </Project>