fsharp(ygosim): feat: refactored to use lenses
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
b102cc39ec
commit
a3c4c78180
488
fsharp/ygosim/.paket/Paket.Restore.targets
Normal file
488
fsharp/ygosim/.paket/Paket.Restore.targets
Normal file
|
@ -0,0 +1,488 @@
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Prevent dotnet template engine to parse this file -->
|
||||||
|
<!--/-:cnd:noEmit-->
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- make MSBuild track this file for incremental builds. -->
|
||||||
|
<!-- ref https://blogs.msdn.microsoft.com/msbuild/2005/09/26/how-to-ensure-changes-to-a-custom-target-file-prompt-a-rebuild/ -->
|
||||||
|
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||||
|
|
||||||
|
<DetectedMSBuildVersion>$(MSBuildVersion)</DetectedMSBuildVersion>
|
||||||
|
<DetectedMSBuildVersion Condition="'$(MSBuildVersion)' == ''">15.0.0</DetectedMSBuildVersion>
|
||||||
|
<MSBuildSupportsHashing>false</MSBuildSupportsHashing>
|
||||||
|
<MSBuildSupportsHashing Condition=" '$(DetectedMSBuildVersion)' > '15.8.0' ">true</MSBuildSupportsHashing>
|
||||||
|
<!-- Mark that this target file has been loaded. -->
|
||||||
|
<IsPaketRestoreTargetsFileLoaded>true</IsPaketRestoreTargetsFileLoaded>
|
||||||
|
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
|
||||||
|
<PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
|
||||||
|
<PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile>
|
||||||
|
<PaketLockFilePath>$(PaketRootPath)paket.lock</PaketLockFilePath>
|
||||||
|
<PaketBootstrapperStyle>classic</PaketBootstrapperStyle>
|
||||||
|
<PaketBootstrapperStyle Condition="Exists('$(PaketToolsPath)paket.bootstrapper.proj')">proj</PaketBootstrapperStyle>
|
||||||
|
<PaketExeImage>assembly</PaketExeImage>
|
||||||
|
<PaketExeImage Condition=" '$(PaketBootstrapperStyle)' == 'proj' ">native</PaketExeImage>
|
||||||
|
<MonoPath Condition="'$(MonoPath)' == '' AND Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
|
||||||
|
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
|
||||||
|
|
||||||
|
<!-- PaketBootStrapper -->
|
||||||
|
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
|
||||||
|
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
|
||||||
|
<PaketBootStrapperExeDir Condition=" Exists('$(PaketBootStrapperExePath)') " >$([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\</PaketBootStrapperExeDir>
|
||||||
|
|
||||||
|
<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT' ">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
|
||||||
|
<PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
|
||||||
|
|
||||||
|
<!-- Disable Paket restore under NCrunch build -->
|
||||||
|
<PaketRestoreDisabled Condition="'$(NCrunch)' == '1'">True</PaketRestoreDisabled>
|
||||||
|
|
||||||
|
<!-- Disable test for CLI tool completely - overrideable via properties in projects or via environment variables -->
|
||||||
|
<PaketDisableCliTest Condition=" '$(PaketDisableCliTest)' == '' ">False</PaketDisableCliTest>
|
||||||
|
|
||||||
|
<PaketIntermediateOutputPath Condition=" '$(PaketIntermediateOutputPath)' == '' ">$(BaseIntermediateOutputPath.TrimEnd('\').TrimEnd('\/'))</PaketIntermediateOutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Resolve how paket should be called -->
|
||||||
|
<!-- 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 -->
|
||||||
|
<Target Name="SetPaketCommand" >
|
||||||
|
<!-- Test if paket is available in the standard locations. If so, that takes priority. Case 1/2 - non-windows specific -->
|
||||||
|
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
|
||||||
|
<!-- no windows, try native paket as default, root => tool -->
|
||||||
|
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket') ">$(PaketRootPath)paket</PaketExePath>
|
||||||
|
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketToolsPath)paket') ">$(PaketToolsPath)paket</PaketExePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Test if paket is available in the standard locations. If so, that takes priority. Case 2/2 - same across platforms -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- root => tool -->
|
||||||
|
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe') ">$(PaketRootPath)paket.exe</PaketExePath>
|
||||||
|
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketToolsPath)paket.exe') ">$(PaketToolsPath)paket.exe</PaketExePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- If paket hasn't be found in standard locations, test for CLI tool usage. -->
|
||||||
|
<!-- First test: Is CLI configured to be used in "dotnet-tools.json"? - can result in a false negative; only a positive outcome is reliable. -->
|
||||||
|
<PropertyGroup Condition=" '$(PaketExePath)' == '' ">
|
||||||
|
<_DotnetToolsJson Condition="Exists('$(PaketRootPath)/.config/dotnet-tools.json')">$([System.IO.File]::ReadAllText("$(PaketRootPath)/.config/dotnet-tools.json"))</_DotnetToolsJson>
|
||||||
|
<_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$(_DotnetToolsJson.Contains('"paket"'))</_ConfigContainsPaket>
|
||||||
|
<_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false</_ConfigContainsPaket>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- 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. -->
|
||||||
|
<!-- 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. -->
|
||||||
|
<Exec Condition=" '$(PaketExePath)' == '' AND !$(PaketDisableCliTest) AND !$(_ConfigContainsPaket)" Command="dotnet paket --version" IgnoreExitCode="true" StandardOutputImportance="low" StandardErrorImportance="low" >
|
||||||
|
<Output TaskParameter="ExitCode" PropertyName="LocalPaketToolExitCode" />
|
||||||
|
</Exec>
|
||||||
|
|
||||||
|
<!-- If paket is installed as CLI use that. Again, only if paket haven't already been found in standard locations. -->
|
||||||
|
<PropertyGroup Condition=" '$(PaketExePath)' == '' AND ($(_ConfigContainsPaket) OR '$(LocalPaketToolExitCode)' == '0') ">
|
||||||
|
<_PaketCommand>dotnet paket</_PaketCommand>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- If neither local files nor CLI tool can be found, final attempt is searching for boostrapper config before falling back to global path variable. -->
|
||||||
|
<PropertyGroup Condition=" '$(PaketExePath)' == '' AND '$(_PaketCommand)' == '' ">
|
||||||
|
<!-- Test for bootstrapper setup -->
|
||||||
|
<PaketExePath Condition=" '$(PaketExePath)' == '' AND '$(PaketBootstrapperStyle)' == 'proj' ">$(PaketToolsPath)paket</PaketExePath>
|
||||||
|
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketBootStrapperExeDir)') ">$(PaketBootStrapperExeDir)paket</PaketExePath>
|
||||||
|
|
||||||
|
<!-- If all else fails, use global path approach. -->
|
||||||
|
<PaketExePath Condition=" '$(PaketExePath)' == ''">paket</PaketExePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- If not using CLI, setup correct execution command. -->
|
||||||
|
<PropertyGroup Condition=" '$(_PaketCommand)' == '' ">
|
||||||
|
<_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))</_PaketExeExtension>
|
||||||
|
<_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</_PaketCommand>
|
||||||
|
<_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</_PaketCommand>
|
||||||
|
<_PaketCommand Condition=" '$(_PaketCommand)' == '' ">"$(PaketExePath)"</_PaketCommand>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- The way to get a property to be available outside the target is to use this task. -->
|
||||||
|
<CreateProperty Value="$(_PaketCommand)">
|
||||||
|
<Output TaskParameter="Value" PropertyName="PaketCommand"/>
|
||||||
|
</CreateProperty>
|
||||||
|
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PaketBootstrapping" Condition="Exists('$(PaketToolsPath)paket.bootstrapper.proj')">
|
||||||
|
<MSBuild Projects="$(PaketToolsPath)paket.bootstrapper.proj" Targets="Restore" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Official workaround for https://docs.microsoft.com/en-us/visualstudio/msbuild/getfilehash-task?view=vs-2019 -->
|
||||||
|
<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' " />
|
||||||
|
<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' " />
|
||||||
|
<Target Name="PaketRestore" Condition="'$(PaketRestoreDisabled)' != 'True'" BeforeTargets="_GenerateDotnetCliToolReferenceSpecs;_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" DependsOnTargets="SetPaketCommand;PaketBootstrapping">
|
||||||
|
|
||||||
|
<!-- Step 1 Check if lockfile is properly restored (if the hash of the lockfile and the cache-file match) -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<PaketRestoreRequired>true</PaketRestoreRequired>
|
||||||
|
<NoWarn>$(NoWarn);NU1603;NU1604;NU1605;NU1608</NoWarn>
|
||||||
|
<CacheFilesExist>false</CacheFilesExist>
|
||||||
|
<CacheFilesExist Condition=" Exists('$(PaketRestoreCacheFile)') And Exists('$(PaketLockFilePath)') ">true</CacheFilesExist>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Read the hash of the lockfile -->
|
||||||
|
<GetFileHash Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' " Files="$(PaketLockFilePath)" Algorithm="SHA256" HashEncoding="hex" >
|
||||||
|
<Output TaskParameter="Hash" PropertyName="PaketRestoreLockFileHash" />
|
||||||
|
</GetFileHash>
|
||||||
|
<!-- Read the hash of the cache, which is json, but a very simple key value object -->
|
||||||
|
<PropertyGroup Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' ">
|
||||||
|
<PaketRestoreCachedContents>$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedContents>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' ">
|
||||||
|
<!-- Parse our simple 'paket.restore.cached' json ...-->
|
||||||
|
<PaketRestoreCachedSplitObject Include="$([System.Text.RegularExpressions.Regex]::Split(`$(PaketRestoreCachedContents)`, `{|}|,`))"></PaketRestoreCachedSplitObject>
|
||||||
|
<!-- Keep Key, Value ItemGroup-->
|
||||||
|
<PaketRestoreCachedKeyValue Include="@(PaketRestoreCachedSplitObject)"
|
||||||
|
Condition=" $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`).Length) > 1 ">
|
||||||
|
<Key>$([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[0].Replace(`"`, ``).Replace(` `, ``))</Key>
|
||||||
|
<Value>$([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[1].Replace(`"`, ``).Replace(` `, ``))</Value>
|
||||||
|
</PaketRestoreCachedKeyValue>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' ">
|
||||||
|
<!-- Retrieve the hashes we are interested in -->
|
||||||
|
<PackagesDownloadedHash Condition=" '%(PaketRestoreCachedKeyValue.Key)' == 'packagesDownloadedHash' ">%(PaketRestoreCachedKeyValue.Value)</PackagesDownloadedHash>
|
||||||
|
<ProjectsRestoredHash Condition=" '%(PaketRestoreCachedKeyValue.Key)' == 'projectsRestoredHash' ">%(PaketRestoreCachedKeyValue.Value)</ProjectsRestoredHash>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(MSBuildSupportsHashing)' == 'true' And '$(CacheFilesExist)' == 'true' ">
|
||||||
|
<!-- If the restore file doesn't exist we need to restore, otherwise only if hashes don't match -->
|
||||||
|
<PaketRestoreRequired>true</PaketRestoreRequired>
|
||||||
|
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(ProjectsRestoredHash)' ">false</PaketRestoreRequired>
|
||||||
|
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This value should match the version in the props generated by paket
|
||||||
|
If they differ, this means we need to do a restore in order to ensure correct dependencies
|
||||||
|
-->
|
||||||
|
<PropertyGroup Condition="'$(PaketPropsVersion)' != '5.185.3' ">
|
||||||
|
<PaketRestoreRequired>true</PaketRestoreRequired>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Do a global restore if required -->
|
||||||
|
<Warning Text="This version of MSBuild (we assume '$(DetectedMSBuildVersion)' or older) doesn't support GetFileHash, so paket fast restore is disabled." Condition=" '$(MSBuildSupportsHashing)' != 'true' " />
|
||||||
|
<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)'))" />
|
||||||
|
<Exec Command='$(PaketBootStrapperCommand)' Condition=" '$(PaketBootstrapperStyle)' == 'classic' AND Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
|
||||||
|
<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'" />
|
||||||
|
<Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(PaketDisableGlobalRestore)' != 'true' " ContinueOnError="false" />
|
||||||
|
|
||||||
|
<!-- Step 2 Detect project specific changes -->
|
||||||
|
<ItemGroup>
|
||||||
|
<MyTargetFrameworks Condition="'$(TargetFramework)' != '' " Include="$(TargetFramework)"></MyTargetFrameworks>
|
||||||
|
<!-- Don't include all frameworks when msbuild explicitly asks for a single one -->
|
||||||
|
<MyTargetFrameworks Condition="'$(TargetFrameworks)' != '' AND '$(TargetFramework)' == '' " Include="$(TargetFrameworks)"></MyTargetFrameworks>
|
||||||
|
<PaketResolvedFilePaths Include="@(MyTargetFrameworks -> '$(PaketIntermediateOutputPath)\$(MSBuildProjectFile).%(Identity).paket.resolved')"></PaketResolvedFilePaths>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<PaketReferencesCachedFilePath>$(PaketIntermediateOutputPath)\$(MSBuildProjectFile).paket.references.cached</PaketReferencesCachedFilePath>
|
||||||
|
<!-- MyProject.fsproj.paket.references has the highest precedence -->
|
||||||
|
<PaketOriginalReferencesFilePath>$(MSBuildProjectFullPath).paket.references</PaketOriginalReferencesFilePath>
|
||||||
|
<!-- MyProject.paket.references -->
|
||||||
|
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketOriginalReferencesFilePath>
|
||||||
|
<!-- paket.references -->
|
||||||
|
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\paket.references</PaketOriginalReferencesFilePath>
|
||||||
|
|
||||||
|
<DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
|
||||||
|
<DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
|
||||||
|
<PaketRestoreRequired>true</PaketRestoreRequired>
|
||||||
|
<PaketRestoreRequiredReason>references-file-or-cache-not-found</PaketRestoreRequiredReason>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Step 2 a Detect changes in references file -->
|
||||||
|
<PropertyGroup Condition="Exists('$(PaketOriginalReferencesFilePath)') AND Exists('$(PaketReferencesCachedFilePath)') ">
|
||||||
|
<PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketReferencesCachedFilePath)'))</PaketRestoreCachedHash>
|
||||||
|
<PaketRestoreReferencesFileHash>$([System.IO.File]::ReadAllText('$(PaketOriginalReferencesFilePath)'))</PaketRestoreReferencesFileHash>
|
||||||
|
<PaketRestoreRequiredReason>references-file</PaketRestoreRequiredReason>
|
||||||
|
<PaketRestoreRequired Condition=" '$(PaketRestoreReferencesFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="!Exists('$(PaketOriginalReferencesFilePath)') AND !Exists('$(PaketReferencesCachedFilePath)') ">
|
||||||
|
<!-- If both don't exist there is nothing to do. -->
|
||||||
|
<PaketRestoreRequired>false</PaketRestoreRequired>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Step 2 b detect relevant changes in project file (new targetframework) -->
|
||||||
|
<PropertyGroup Condition=" '$(DoAllResolvedFilesExist)' != 'true' ">
|
||||||
|
<PaketRestoreRequired>true</PaketRestoreRequired>
|
||||||
|
<PaketRestoreRequiredReason>target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths)</PaketRestoreRequiredReason>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Step 3 Restore project specific stuff if required -->
|
||||||
|
<Message Condition=" '$(PaketRestoreRequired)' == 'true' " Importance="low" Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" />
|
||||||
|
<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' " />
|
||||||
|
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" --output-path "$(PaketIntermediateOutputPath)" --target-framework "$(TargetFrameworks)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' == '' " ContinueOnError="false" />
|
||||||
|
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" --output-path "$(PaketIntermediateOutputPath)" --target-framework "$(TargetFramework)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' != '' " ContinueOnError="false" />
|
||||||
|
|
||||||
|
<!-- This shouldn't actually happen, but just to be sure. -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
|
||||||
|
<DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
|
||||||
|
</PropertyGroup>
|
||||||
|
<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'." />
|
||||||
|
|
||||||
|
<!-- Step 4 forward all msbuild properties (PackageReference, DotNetCliToolReference) to msbuild -->
|
||||||
|
<ReadLinesFromFile Condition="($(DesignTimeBuild) != true OR '$(PaketPropsLoaded)' != 'true') AND '@(PaketResolvedFilePaths)' != ''" File="%(PaketResolvedFilePaths.Identity)" >
|
||||||
|
<Output TaskParameter="Lines" ItemName="PaketReferencesFileLines"/>
|
||||||
|
</ReadLinesFromFile>
|
||||||
|
|
||||||
|
<ItemGroup Condition="($(DesignTimeBuild) != true OR '$(PaketPropsLoaded)' != 'true') AND '@(PaketReferencesFileLines)' != '' " >
|
||||||
|
<PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
|
||||||
|
<Splits>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length)</Splits>
|
||||||
|
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
|
||||||
|
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
|
||||||
|
<AllPrivateAssets>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])</AllPrivateAssets>
|
||||||
|
<CopyLocal Condition="'%(PaketReferencesFileLinesInfo.Splits)' == '6'">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])</CopyLocal>
|
||||||
|
</PaketReferencesFileLinesInfo>
|
||||||
|
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
|
||||||
|
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
|
||||||
|
<PrivateAssets Condition=" ('%(PaketReferencesFileLinesInfo.AllPrivateAssets)' == 'true') Or ('$(PackAsTool)' == 'true') ">All</PrivateAssets>
|
||||||
|
<ExcludeAssets Condition=" '%(PaketReferencesFileLinesInfo.Splits)' == '6' And %(PaketReferencesFileLinesInfo.CopyLocal) == 'false'">runtime</ExcludeAssets>
|
||||||
|
<ExcludeAssets Condition=" '%(PaketReferencesFileLinesInfo.Splits)' != '6' And %(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'">runtime</ExcludeAssets>
|
||||||
|
<Publish Condition=" '$(PackAsTool)' == 'true' ">true</Publish>
|
||||||
|
<AllowExplicitVersion>true</AllowExplicitVersion>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<PaketCliToolFilePath>$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).paket.clitools</PaketCliToolFilePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ReadLinesFromFile File="$(PaketCliToolFilePath)" >
|
||||||
|
<Output TaskParameter="Lines" ItemName="PaketCliToolFileLines"/>
|
||||||
|
</ReadLinesFromFile>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '@(PaketCliToolFileLines)' != '' " >
|
||||||
|
<PaketCliToolFileLinesInfo Include="@(PaketCliToolFileLines)" >
|
||||||
|
<PackageName>$([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[0])</PackageName>
|
||||||
|
<PackageVersion>$([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[1])</PackageVersion>
|
||||||
|
</PaketCliToolFileLinesInfo>
|
||||||
|
<DotNetCliToolReference Include="%(PaketCliToolFileLinesInfo.PackageName)">
|
||||||
|
<Version>%(PaketCliToolFileLinesInfo.PackageVersion)</Version>
|
||||||
|
</DotNetCliToolReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Disabled for now until we know what to do with runtime deps - https://github.com/fsprojects/Paket/issues/2964
|
||||||
|
<PropertyGroup>
|
||||||
|
<RestoreConfigFile>$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).NuGet.Config</RestoreConfigFile>
|
||||||
|
</PropertyGroup> -->
|
||||||
|
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PaketDisableDirectPack" AfterTargets="_IntermediatePack" BeforeTargets="GenerateNuspec" Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).references')" >
|
||||||
|
<PropertyGroup>
|
||||||
|
<ContinuePackingAfterGeneratingNuspec>false</ContinuePackingAfterGeneratingNuspec>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PaketOverrideNuspec" DependsOnTargets="SetPaketCommand" AfterTargets="GenerateNuspec" Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).references')" >
|
||||||
|
<ItemGroup>
|
||||||
|
<_NuspecFilesNewLocation Include="$(PaketIntermediateOutputPath)\$(Configuration)\*.nuspec"/>
|
||||||
|
<MSBuildMajorVersion Include="$(DetectedMSBuildVersion.Replace(`-`, `.`).Split(`.`)[0])" />
|
||||||
|
<MSBuildMinorVersion Include="$(DetectedMSBuildVersion.Replace(`-`, `.`).Split(`.`)[1])" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<PaketProjectFile>$(MSBuildProjectDirectory)/$(MSBuildProjectFile)</PaketProjectFile>
|
||||||
|
<ContinuePackingAfterGeneratingNuspec>true</ContinuePackingAfterGeneratingNuspec>
|
||||||
|
<UseMSBuild16_0_Pack>false</UseMSBuild16_0_Pack>
|
||||||
|
<UseMSBuild16_0_Pack Condition=" '@(MSBuildMajorVersion)' >= '16' ">true</UseMSBuild16_0_Pack>
|
||||||
|
<UseMSBuild15_9_Pack>false</UseMSBuild15_9_Pack>
|
||||||
|
<UseMSBuild15_9_Pack Condition=" '@(MSBuildMajorVersion)' == '15' AND '@(MSBuildMinorVersion)' > '8' ">true</UseMSBuild15_9_Pack>
|
||||||
|
<UseMSBuild15_8_Pack>false</UseMSBuild15_8_Pack>
|
||||||
|
<UseMSBuild15_8_Pack Condition=" '$(NuGetToolVersion)' != '4.0.0' AND (! $(UseMSBuild15_9_Pack)) AND (! $(UseMSBuild16_0_Pack)) ">true</UseMSBuild15_8_Pack>
|
||||||
|
<UseNuGet4_Pack>false</UseNuGet4_Pack>
|
||||||
|
<UseNuGet4_Pack Condition=" (! $(UseMSBuild15_8_Pack)) AND (! $(UseMSBuild15_9_Pack)) AND (! $(UseMSBuild16_0_Pack)) ">true</UseNuGet4_Pack>
|
||||||
|
<AdjustedNuspecOutputPath>$(PaketIntermediateOutputPath)\$(Configuration)</AdjustedNuspecOutputPath>
|
||||||
|
<AdjustedNuspecOutputPath Condition="@(_NuspecFilesNewLocation) == ''">$(PaketIntermediateOutputPath)</AdjustedNuspecOutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<_NuspecFiles Include="$(AdjustedNuspecOutputPath)\*.$(PackageVersion.Split(`+`)[0]).nuspec"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Error Text="Error Because of PAKET_ERROR_ON_MSBUILD_EXEC (not calling fix-nuspecs)" Condition=" '$(PAKET_ERROR_ON_MSBUILD_EXEC)' == 'true' " />
|
||||||
|
<Exec Condition="@(_NuspecFiles) != ''" Command='$(PaketCommand) fix-nuspecs files "@(_NuspecFiles)" project-file "$(PaketProjectFile)" ' />
|
||||||
|
<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!' />
|
||||||
|
|
||||||
|
<ConvertToAbsolutePath Condition="@(_NuspecFiles) != ''" Paths="@(_NuspecFiles)">
|
||||||
|
<Output TaskParameter="AbsolutePaths" PropertyName="NuspecFileAbsolutePath" />
|
||||||
|
</ConvertToAbsolutePath>
|
||||||
|
|
||||||
|
<!-- Call Pack -->
|
||||||
|
<PackTask Condition="$(UseMSBuild16_0_Pack)"
|
||||||
|
PackItem="$(PackProjectInputFile)"
|
||||||
|
PackageFiles="@(_PackageFiles)"
|
||||||
|
PackageFilesToExclude="@(_PackageFilesToExclude)"
|
||||||
|
PackageVersion="$(PackageVersion)"
|
||||||
|
PackageId="$(PackageId)"
|
||||||
|
Title="$(Title)"
|
||||||
|
Authors="$(Authors)"
|
||||||
|
Description="$(Description)"
|
||||||
|
Copyright="$(Copyright)"
|
||||||
|
RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
|
||||||
|
LicenseUrl="$(PackageLicenseUrl)"
|
||||||
|
ProjectUrl="$(PackageProjectUrl)"
|
||||||
|
IconUrl="$(PackageIconUrl)"
|
||||||
|
ReleaseNotes="$(PackageReleaseNotes)"
|
||||||
|
Tags="$(PackageTags)"
|
||||||
|
DevelopmentDependency="$(DevelopmentDependency)"
|
||||||
|
BuildOutputInPackage="@(_BuildOutputInPackage)"
|
||||||
|
TargetPathsToSymbols="@(_TargetPathsToSymbols)"
|
||||||
|
SymbolPackageFormat="$(SymbolPackageFormat)"
|
||||||
|
TargetFrameworks="@(_TargetFrameworks)"
|
||||||
|
AssemblyName="$(AssemblyName)"
|
||||||
|
PackageOutputPath="$(PackageOutputAbsolutePath)"
|
||||||
|
IncludeSymbols="$(IncludeSymbols)"
|
||||||
|
IncludeSource="$(IncludeSource)"
|
||||||
|
PackageTypes="$(PackageType)"
|
||||||
|
IsTool="$(IsTool)"
|
||||||
|
RepositoryUrl="$(RepositoryUrl)"
|
||||||
|
RepositoryType="$(RepositoryType)"
|
||||||
|
SourceFiles="@(_SourceFiles->Distinct())"
|
||||||
|
NoPackageAnalysis="$(NoPackageAnalysis)"
|
||||||
|
MinClientVersion="$(MinClientVersion)"
|
||||||
|
Serviceable="$(Serviceable)"
|
||||||
|
FrameworkAssemblyReferences="@(_FrameworkAssemblyReferences)"
|
||||||
|
ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
|
||||||
|
NuspecOutputPath="$(AdjustedNuspecOutputPath)"
|
||||||
|
IncludeBuildOutput="$(IncludeBuildOutput)"
|
||||||
|
BuildOutputFolders="$(BuildOutputTargetFolder)"
|
||||||
|
ContentTargetFolders="$(ContentTargetFolders)"
|
||||||
|
RestoreOutputPath="$(RestoreOutputAbsolutePath)"
|
||||||
|
NuspecFile="$(NuspecFileAbsolutePath)"
|
||||||
|
NuspecBasePath="$(NuspecBasePath)"
|
||||||
|
NuspecProperties="$(NuspecProperties)"
|
||||||
|
PackageLicenseFile="$(PackageLicenseFile)"
|
||||||
|
PackageLicenseExpression="$(PackageLicenseExpression)"
|
||||||
|
PackageLicenseExpressionVersion="$(PackageLicenseExpressionVersion)" />
|
||||||
|
|
||||||
|
<PackTask Condition="$(UseMSBuild15_9_Pack)"
|
||||||
|
PackItem="$(PackProjectInputFile)"
|
||||||
|
PackageFiles="@(_PackageFiles)"
|
||||||
|
PackageFilesToExclude="@(_PackageFilesToExclude)"
|
||||||
|
PackageVersion="$(PackageVersion)"
|
||||||
|
PackageId="$(PackageId)"
|
||||||
|
Title="$(Title)"
|
||||||
|
Authors="$(Authors)"
|
||||||
|
Description="$(Description)"
|
||||||
|
Copyright="$(Copyright)"
|
||||||
|
RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
|
||||||
|
LicenseUrl="$(PackageLicenseUrl)"
|
||||||
|
ProjectUrl="$(PackageProjectUrl)"
|
||||||
|
IconUrl="$(PackageIconUrl)"
|
||||||
|
ReleaseNotes="$(PackageReleaseNotes)"
|
||||||
|
Tags="$(PackageTags)"
|
||||||
|
DevelopmentDependency="$(DevelopmentDependency)"
|
||||||
|
BuildOutputInPackage="@(_BuildOutputInPackage)"
|
||||||
|
TargetPathsToSymbols="@(_TargetPathsToSymbols)"
|
||||||
|
SymbolPackageFormat="$(SymbolPackageFormat)"
|
||||||
|
TargetFrameworks="@(_TargetFrameworks)"
|
||||||
|
AssemblyName="$(AssemblyName)"
|
||||||
|
PackageOutputPath="$(PackageOutputAbsolutePath)"
|
||||||
|
IncludeSymbols="$(IncludeSymbols)"
|
||||||
|
IncludeSource="$(IncludeSource)"
|
||||||
|
PackageTypes="$(PackageType)"
|
||||||
|
IsTool="$(IsTool)"
|
||||||
|
RepositoryUrl="$(RepositoryUrl)"
|
||||||
|
RepositoryType="$(RepositoryType)"
|
||||||
|
SourceFiles="@(_SourceFiles->Distinct())"
|
||||||
|
NoPackageAnalysis="$(NoPackageAnalysis)"
|
||||||
|
MinClientVersion="$(MinClientVersion)"
|
||||||
|
Serviceable="$(Serviceable)"
|
||||||
|
FrameworkAssemblyReferences="@(_FrameworkAssemblyReferences)"
|
||||||
|
ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
|
||||||
|
NuspecOutputPath="$(AdjustedNuspecOutputPath)"
|
||||||
|
IncludeBuildOutput="$(IncludeBuildOutput)"
|
||||||
|
BuildOutputFolder="$(BuildOutputTargetFolder)"
|
||||||
|
ContentTargetFolders="$(ContentTargetFolders)"
|
||||||
|
RestoreOutputPath="$(RestoreOutputAbsolutePath)"
|
||||||
|
NuspecFile="$(NuspecFileAbsolutePath)"
|
||||||
|
NuspecBasePath="$(NuspecBasePath)"
|
||||||
|
NuspecProperties="$(NuspecProperties)"/>
|
||||||
|
|
||||||
|
<PackTask Condition="$(UseMSBuild15_8_Pack)"
|
||||||
|
PackItem="$(PackProjectInputFile)"
|
||||||
|
PackageFiles="@(_PackageFiles)"
|
||||||
|
PackageFilesToExclude="@(_PackageFilesToExclude)"
|
||||||
|
PackageVersion="$(PackageVersion)"
|
||||||
|
PackageId="$(PackageId)"
|
||||||
|
Title="$(Title)"
|
||||||
|
Authors="$(Authors)"
|
||||||
|
Description="$(Description)"
|
||||||
|
Copyright="$(Copyright)"
|
||||||
|
RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
|
||||||
|
LicenseUrl="$(PackageLicenseUrl)"
|
||||||
|
ProjectUrl="$(PackageProjectUrl)"
|
||||||
|
IconUrl="$(PackageIconUrl)"
|
||||||
|
ReleaseNotes="$(PackageReleaseNotes)"
|
||||||
|
Tags="$(PackageTags)"
|
||||||
|
DevelopmentDependency="$(DevelopmentDependency)"
|
||||||
|
BuildOutputInPackage="@(_BuildOutputInPackage)"
|
||||||
|
TargetPathsToSymbols="@(_TargetPathsToSymbols)"
|
||||||
|
TargetFrameworks="@(_TargetFrameworks)"
|
||||||
|
AssemblyName="$(AssemblyName)"
|
||||||
|
PackageOutputPath="$(PackageOutputAbsolutePath)"
|
||||||
|
IncludeSymbols="$(IncludeSymbols)"
|
||||||
|
IncludeSource="$(IncludeSource)"
|
||||||
|
PackageTypes="$(PackageType)"
|
||||||
|
IsTool="$(IsTool)"
|
||||||
|
RepositoryUrl="$(RepositoryUrl)"
|
||||||
|
RepositoryType="$(RepositoryType)"
|
||||||
|
SourceFiles="@(_SourceFiles->Distinct())"
|
||||||
|
NoPackageAnalysis="$(NoPackageAnalysis)"
|
||||||
|
MinClientVersion="$(MinClientVersion)"
|
||||||
|
Serviceable="$(Serviceable)"
|
||||||
|
FrameworkAssemblyReferences="@(_FrameworkAssemblyReferences)"
|
||||||
|
ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
|
||||||
|
NuspecOutputPath="$(AdjustedNuspecOutputPath)"
|
||||||
|
IncludeBuildOutput="$(IncludeBuildOutput)"
|
||||||
|
BuildOutputFolder="$(BuildOutputTargetFolder)"
|
||||||
|
ContentTargetFolders="$(ContentTargetFolders)"
|
||||||
|
RestoreOutputPath="$(RestoreOutputAbsolutePath)"
|
||||||
|
NuspecFile="$(NuspecFileAbsolutePath)"
|
||||||
|
NuspecBasePath="$(NuspecBasePath)"
|
||||||
|
NuspecProperties="$(NuspecProperties)"/>
|
||||||
|
|
||||||
|
<PackTask Condition="$(UseNuGet4_Pack)"
|
||||||
|
PackItem="$(PackProjectInputFile)"
|
||||||
|
PackageFiles="@(_PackageFiles)"
|
||||||
|
PackageFilesToExclude="@(_PackageFilesToExclude)"
|
||||||
|
PackageVersion="$(PackageVersion)"
|
||||||
|
PackageId="$(PackageId)"
|
||||||
|
Title="$(Title)"
|
||||||
|
Authors="$(Authors)"
|
||||||
|
Description="$(Description)"
|
||||||
|
Copyright="$(Copyright)"
|
||||||
|
RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
|
||||||
|
LicenseUrl="$(PackageLicenseUrl)"
|
||||||
|
ProjectUrl="$(PackageProjectUrl)"
|
||||||
|
IconUrl="$(PackageIconUrl)"
|
||||||
|
ReleaseNotes="$(PackageReleaseNotes)"
|
||||||
|
Tags="$(PackageTags)"
|
||||||
|
TargetPathsToAssemblies="@(_TargetPathsToAssemblies->'%(FinalOutputPath)')"
|
||||||
|
TargetPathsToSymbols="@(_TargetPathsToSymbols)"
|
||||||
|
TargetFrameworks="@(_TargetFrameworks)"
|
||||||
|
AssemblyName="$(AssemblyName)"
|
||||||
|
PackageOutputPath="$(PackageOutputAbsolutePath)"
|
||||||
|
IncludeSymbols="$(IncludeSymbols)"
|
||||||
|
IncludeSource="$(IncludeSource)"
|
||||||
|
PackageTypes="$(PackageType)"
|
||||||
|
IsTool="$(IsTool)"
|
||||||
|
RepositoryUrl="$(RepositoryUrl)"
|
||||||
|
RepositoryType="$(RepositoryType)"
|
||||||
|
SourceFiles="@(_SourceFiles->Distinct())"
|
||||||
|
NoPackageAnalysis="$(NoPackageAnalysis)"
|
||||||
|
MinClientVersion="$(MinClientVersion)"
|
||||||
|
Serviceable="$(Serviceable)"
|
||||||
|
AssemblyReferences="@(_References)"
|
||||||
|
ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
|
||||||
|
NuspecOutputPath="$(AdjustedNuspecOutputPath)"
|
||||||
|
IncludeBuildOutput="$(IncludeBuildOutput)"
|
||||||
|
BuildOutputFolder="$(BuildOutputTargetFolder)"
|
||||||
|
ContentTargetFolders="$(ContentTargetFolders)"
|
||||||
|
RestoreOutputPath="$(RestoreOutputAbsolutePath)"
|
||||||
|
NuspecFile="$(NuspecFileAbsolutePath)"
|
||||||
|
NuspecBasePath="$(NuspecBasePath)"
|
||||||
|
NuspecProperties="$(NuspecProperties)"/>
|
||||||
|
</Target>
|
||||||
|
<!--/+:cnd:noEmit-->
|
||||||
|
</Project>
|
|
@ -2,4 +2,4 @@ source https://api.nuget.org/v3/index.json
|
||||||
|
|
||||||
storage: none
|
storage: none
|
||||||
framework: netcore3.0, netstandard2.0, netstandard2.1
|
framework: netcore3.0, netstandard2.0, netstandard2.1
|
||||||
nuget FSharpPlus 1.0.0
|
nuget FSharpPlus 1.1.0-CI00252
|
|
@ -3,5 +3,5 @@ RESTRICTION: || (== netcoreapp3.0) (== netstandard2.0) (== netstandard2.1)
|
||||||
NUGET
|
NUGET
|
||||||
remote: https://api.nuget.org/v3/index.json
|
remote: https://api.nuget.org/v3/index.json
|
||||||
FSharp.Core (4.7)
|
FSharp.Core (4.7)
|
||||||
FSharpPlus (1.0)
|
FSharpPlus (1.1.0-CI00252)
|
||||||
FSharp.Core (>= 4.3.4)
|
FSharp.Core (>= 4.3.4)
|
||||||
|
|
1
fsharp/ygosim/paket.references
Normal file
1
fsharp/ygosim/paket.references
Normal file
|
@ -0,0 +1 @@
|
||||||
|
FSharpPlus
|
|
@ -1,5 +1,7 @@
|
||||||
module Board
|
module Board
|
||||||
|
|
||||||
|
open FSharpPlus.Lens
|
||||||
|
|
||||||
module Side =
|
module Side =
|
||||||
open Card.Card
|
open Card.Card
|
||||||
|
|
||||||
|
@ -10,6 +12,13 @@ module Side =
|
||||||
graveyard: CardInstance<'s> list
|
graveyard: CardInstance<'s> list
|
||||||
deck: CardInstance<'s> list }
|
deck: CardInstance<'s> list }
|
||||||
|
|
||||||
|
module Side =
|
||||||
|
let inline field f side = f side.field <&> fun v -> { side with field = v }
|
||||||
|
let inline monsters f side = f side.monsters <&> fun v -> { side with monsters = v }
|
||||||
|
let inline spells f side = f side.spells <&> fun v -> { side with spells = v }
|
||||||
|
let inline graveyard f side = f side.graveyard <&> fun v -> { side with graveyard = v }
|
||||||
|
let inline deck f side = f side.deck <&> fun v -> { side with deck = v }
|
||||||
|
|
||||||
let emptySide =
|
let emptySide =
|
||||||
{ field = None
|
{ field = None
|
||||||
monsters = []
|
monsters = []
|
||||||
|
@ -33,6 +42,13 @@ module Player =
|
||||||
hand: CardInstance<'s> list
|
hand: CardInstance<'s> list
|
||||||
state: PlayerState }
|
state: PlayerState }
|
||||||
|
|
||||||
|
module Player =
|
||||||
|
let inline lifePoints f player = f player.lifePoints <&> fun v -> { player with lifePoints = v }
|
||||||
|
let inline side f player = f player.side <&> fun v -> { player with side = v }
|
||||||
|
let inline hand f player = f player.hand <&> fun v -> { player with hand = v }
|
||||||
|
let inline state f player = f player.state <&> fun v -> { player with state = v }
|
||||||
|
let inline deck f player = (side << Side.deck) f player
|
||||||
|
|
||||||
let initialPlayer lp =
|
let initialPlayer lp =
|
||||||
{ lifePoints = lp
|
{ lifePoints = lp
|
||||||
side = emptySide
|
side = emptySide
|
||||||
|
@ -50,14 +66,14 @@ module Turn =
|
||||||
| Main2
|
| Main2
|
||||||
| End
|
| End
|
||||||
|
|
||||||
let nextPhase (previous: Phase) (turn: int) =
|
let nextPhase (turn, phase) =
|
||||||
match previous with
|
match phase with
|
||||||
| Draw -> (Standby, turn)
|
| Draw -> (turn, Standby)
|
||||||
| Standby -> (Main1, turn)
|
| Standby -> (turn, Main1)
|
||||||
| Main1 -> (Battle, turn)
|
| Main1 -> (turn, Battle)
|
||||||
| Battle -> (Main2, turn)
|
| Battle -> (turn, Main2)
|
||||||
| Main2 -> (End, turn)
|
| Main2 -> (turn, End)
|
||||||
| End -> (Draw, turn + 1)
|
| End -> (turn + 1, Draw)
|
||||||
|
|
||||||
module Board =
|
module Board =
|
||||||
open Turn
|
open Turn
|
||||||
|
@ -67,8 +83,18 @@ module Board =
|
||||||
|
|
||||||
and Board =
|
and Board =
|
||||||
{ players: Player * Player
|
{ players: Player * Player
|
||||||
turn: int
|
moment: int * Phase }
|
||||||
phase: Phase }
|
|
||||||
|
module Board =
|
||||||
|
let inline players f board = f board.players <&> fun v -> { board with players = v }
|
||||||
|
let inline moment f board = f board.moment <&> fun v -> { board with moment = v }
|
||||||
|
|
||||||
|
let inline turn f board = (moment << _1) f board
|
||||||
|
let inline phase f board = (moment << _2) f board
|
||||||
|
|
||||||
|
let inline currentPlayer f board =
|
||||||
|
if (view turn board) % 2 = 0 then (players << _2) f board
|
||||||
|
else (players << _1) f board
|
||||||
|
|
||||||
type Card = Card.Card<Board>
|
type Card = Card.Card<Board>
|
||||||
|
|
||||||
|
@ -82,13 +108,13 @@ module Board =
|
||||||
|
|
||||||
let emptyBoard =
|
let emptyBoard =
|
||||||
{ players = (Player.initialPlayer 8000, Player.initialPlayer 8000)
|
{ players = (Player.initialPlayer 8000, Player.initialPlayer 8000)
|
||||||
turn = 0
|
moment = 0, Draw }
|
||||||
phase = Draw }
|
|
||||||
|
|
||||||
module Game =
|
module Game =
|
||||||
open Board
|
open Board
|
||||||
open Turn
|
open Turn
|
||||||
open Player
|
open Player
|
||||||
|
open Side
|
||||||
|
|
||||||
type PlayerAction =
|
type PlayerAction =
|
||||||
| Pass
|
| Pass
|
||||||
|
@ -97,46 +123,23 @@ module Game =
|
||||||
| Activate
|
| Activate
|
||||||
| Set
|
| Set
|
||||||
|
|
||||||
// let canDoInitialDraw (board: Board) =
|
|
||||||
|
|
||||||
|
|
||||||
let draw (player: Player) =
|
let draw (player: Player) =
|
||||||
match player.side.deck with
|
match player.side.deck with
|
||||||
| [] -> { player with state = Lost "deckout" }
|
| [] -> player |> Player.state .-> Lost "deckout"
|
||||||
| card :: deck ->
|
| card :: deck ->
|
||||||
{ player with
|
let hand = card :: player.hand
|
||||||
hand = card :: player.hand
|
|
||||||
side = { player.side with deck = deck } }
|
player
|
||||||
|
|> Player.hand .-> hand
|
||||||
|
|> Player.deck .-> deck
|
||||||
|
|
||||||
// Player is the last arg to be able to use this with the withCurrentPlayer function
|
// Player is the last arg to be able to use this with the withCurrentPlayer function
|
||||||
let toDeckBottom (card: CardInstance) (player: Player) =
|
let toDeckBottom (card: CardInstance) (player: Player) = over Player.deck (fun d -> card :: d) player
|
||||||
{ player with side = { player.side with deck = card :: player.side.deck } }
|
|
||||||
|
|
||||||
let currentPlayer (board: Board) =
|
|
||||||
let (first, second) = board.players
|
|
||||||
|
|
||||||
if board.turn % 2 = 0 then first
|
|
||||||
else second
|
|
||||||
|
|
||||||
let withCurrentPlayer callback board =
|
|
||||||
let (first, second) = board.players
|
|
||||||
|
|
||||||
let players =
|
|
||||||
if board.turn % 2 = 0 then (callback first, second)
|
|
||||||
else (first, callback second)
|
|
||||||
|
|
||||||
{ board with players = players }
|
|
||||||
|
|
||||||
|
|
||||||
let processTurn (board: Board) =
|
let processTurn (board: Board) =
|
||||||
match board.phase with
|
match board ^. Board.phase with
|
||||||
| Draw -> withCurrentPlayer draw board
|
| Draw -> over Board.currentPlayer draw board
|
||||||
| _ -> board
|
| _ -> board
|
||||||
|
|
||||||
let doTurn (board: Board) =
|
let doTurn (board: Board) = over Board.moment nextPhase <| processTurn board
|
||||||
let newBoard = processTurn board
|
|
||||||
let (phase, turn) = nextPhase newBoard.phase newBoard.turn
|
|
||||||
|
|
||||||
{ newBoard with
|
|
||||||
turn = turn
|
|
||||||
phase = phase }
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
module Card
|
module Card
|
||||||
|
|
||||||
|
open FSharpPlus.Lens
|
||||||
|
|
||||||
module Effect =
|
module Effect =
|
||||||
type Condition<'s> = 's -> bool
|
type Condition<'s> = 's -> bool
|
||||||
|
@ -8,6 +9,10 @@ module Effect =
|
||||||
{ condition: Condition<'s>
|
{ condition: Condition<'s>
|
||||||
resolution: 's -> 's }
|
resolution: 's -> 's }
|
||||||
|
|
||||||
|
module Action =
|
||||||
|
let inline condition f action = f action.condition <&> fun c -> { action with condition = c }
|
||||||
|
let inline resolution f action = f action.resolution <&> fun r -> { action with resolution = r }
|
||||||
|
|
||||||
type EffectType =
|
type EffectType =
|
||||||
| Trigger
|
| Trigger
|
||||||
| Ignition
|
| Ignition
|
||||||
|
@ -17,6 +22,11 @@ module Effect =
|
||||||
resolve: Action<'s>
|
resolve: Action<'s>
|
||||||
_type: EffectType }
|
_type: EffectType }
|
||||||
|
|
||||||
|
module Effect =
|
||||||
|
let inline cost f effect = f effect.cost <&> fun c -> { effect with cost = c }
|
||||||
|
let inline resolve f effect = f effect.resolve <&> fun r -> { effect with resolve = r }
|
||||||
|
let inline _type f effect = f effect._type <&> fun t -> { effect with _type = t }
|
||||||
|
|
||||||
|
|
||||||
module Card =
|
module Card =
|
||||||
open Effect
|
open Effect
|
||||||
|
@ -26,6 +36,11 @@ module Card =
|
||||||
text: string
|
text: string
|
||||||
effects: Effect<'s> list }
|
effects: Effect<'s> list }
|
||||||
|
|
||||||
|
module BaseCard =
|
||||||
|
let inline name f card = f card.name <&> fun v -> { card with name = v }
|
||||||
|
let inline text f card = f card.text <&> fun v -> { card with text = v }
|
||||||
|
let inline effects f card = f card.effects <&> fun v -> { card with effects = v }
|
||||||
|
|
||||||
type SpellCardType =
|
type SpellCardType =
|
||||||
| NormalSpell
|
| NormalSpell
|
||||||
| Field
|
| Field
|
||||||
|
@ -78,9 +93,15 @@ module Card =
|
||||||
type SpellCardDetails =
|
type SpellCardDetails =
|
||||||
{ spellType: SpellCardType }
|
{ spellType: SpellCardType }
|
||||||
|
|
||||||
|
module SpellCardDetails =
|
||||||
|
let inline spellType f card = f card.spellType <&> fun v -> { card with spellType = v }
|
||||||
|
|
||||||
type TrapCardDetails =
|
type TrapCardDetails =
|
||||||
{ trapType: TrapCardType }
|
{ trapType: TrapCardType }
|
||||||
|
|
||||||
|
module TrapCardDetails =
|
||||||
|
let inline trapType f card = f card.trapType <&> fun v -> { card with trapType = v }
|
||||||
|
|
||||||
|
|
||||||
type MonsterCardDetails =
|
type MonsterCardDetails =
|
||||||
{ attack: int
|
{ attack: int
|
||||||
|
@ -88,12 +109,22 @@ module Card =
|
||||||
attribute: Attribute
|
attribute: Attribute
|
||||||
level: int }
|
level: int }
|
||||||
|
|
||||||
|
module MonsterCardDetails =
|
||||||
|
let inline attack f card = f card.attack <&> fun v -> { card with attack = v }
|
||||||
|
let inline trapType f card = f card.defense <&> fun v -> { card with defense = v }
|
||||||
|
let inline attribute f card = f card.attribute <&> fun v -> { card with attribute = v }
|
||||||
|
let inline level f card = f card.level <&> fun v -> { card with level = v }
|
||||||
|
|
||||||
|
|
||||||
type Card<'s> =
|
type Card<'s> =
|
||||||
| Monster of BaseCard<'s> * MonsterCardDetails
|
| Monster of BaseCard<'s> * MonsterCardDetails
|
||||||
| Spell of BaseCard<'s> * SpellCardDetails
|
| Spell of BaseCard<'s> * SpellCardDetails
|
||||||
| Trap of BaseCard<'s> * TrapCardDetails
|
| Trap of BaseCard<'s> * TrapCardDetails
|
||||||
|
|
||||||
|
module Card =
|
||||||
|
let inline baseCard f card = _1 f card
|
||||||
|
let inline cardDetails f card = _2 f card
|
||||||
|
|
||||||
// TODO: actually make this do what its supposed to
|
// TODO: actually make this do what its supposed to
|
||||||
type CardInstance<'s> = Card<'s>
|
type CardInstance<'s> = Card<'s>
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
module Main =
|
module Main =
|
||||||
open Board
|
open FSharpPlus.Lens
|
||||||
|
open Board.Board
|
||||||
|
open Board.Game
|
||||||
open Card
|
open Card
|
||||||
open Game
|
|
||||||
|
|
||||||
[<EntryPoint>]
|
[<EntryPoint>]
|
||||||
let main _ =
|
let main _ =
|
||||||
let board = Board.emptyBoard
|
let board = emptyBoard
|
||||||
let sampleCard = Card.Spell ({name= "sampleCard"; text="something"; effects = []}, {spellType = Card.ContinuosSpell})
|
let sampleCard = Card.Spell ({name= "sampleCard"; text="something"; effects = []}, {spellType = Card.ContinuosSpell})
|
||||||
|
|
||||||
let secondBoard = withCurrentPlayer <| Game.toDeckBottom sampleCard <| board
|
let secondBoard = over Board.currentPlayer <| toDeckBottom sampleCard <| board
|
||||||
|
|
||||||
printfn "%A" secondBoard
|
printfn "%A" secondBoard
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="src/Card.fs" />
|
<Compile Include="src/Card.fs" />
|
||||||
<Compile Include="src/Board.fs" />
|
<Compile Include="src/Board.fs" />
|
||||||
<Compile Include="src/Program.fs" />
|
<Compile Include="src/Program.fs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<Import Project=".paket\Paket.Restore.targets" />
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in a new issue