Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
997 changes: 497 additions & 500 deletions .paket/Paket.Restore.targets

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"paket-files",
"integrationtests/scenarios",
"packages"
]
],
"editor.inlayHints.enabled": "offUnlessPressed"
}
2 changes: 1 addition & 1 deletion integrationtests/Paket.IntegrationTests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="6.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<Compile Include="NugetDownloadSpecs.fs" />
<Compile Include="InitSpecs.fs" />
<Compile Include="InfoSpecs.fs" />
<Compile Include="OutdatedSpecs.fs" />
<Compile Include="NuGetV3Specs.fs" />
<Compile Include="UpdatePackageSpecs.fs" />
<Compile Include="UpdateGroupsSpecs.fs" />
Expand Down
2 changes: 1 addition & 1 deletion integrationtests/Paket.IntegrationTests/PaketCoreSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ open System
open System.IO
open System.Diagnostics
open Paket
open Chessie.ErrorHandling
open FsToolkit.ErrorHandling
open Paket.Domain

let alternativeProjectRoot = None
Expand Down
1 change: 0 additions & 1 deletion integrationtests/Paket.IntegrationTests/paket.references
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FSharp.Core
FSharp.Compiler.Service
Chessie
Newtonsoft.Json
Microsoft.NET.Test.Sdk
NUnit
Expand Down
5 changes: 3 additions & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ source https://api.nuget.org/v3/index.json
storage: none
content: none

nuget FsToolkit.ErrorHandling > 4
nuget Newtonsoft.Json >= 10.0.3 redirects: force
nuget Argu >= 5.1.0
nuget FSharp.Core = 6.0.3 redirects: force
nuget Chessie >= 0.6
nuget FSharp.Core >= 6.0.3 redirects: force
nuget Mono.Cecil ~> 0.11.1

nuget System.Security.Cryptography.ProtectedData >= 4.4
nuget System.Security.Permissions >= 6

nuget NETStandard.Library ~> 2.0
nuget Microsoft.NETCore.App ~> 2.1
Expand Down
311 changes: 84 additions & 227 deletions paket.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/Paket.Core/Common/NetUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open System.Text
open Paket
open Paket.Logging
open Paket.Constants
open Chessie.ErrorHandling
open FsToolkit.ErrorHandling
open Paket.Domain
open Paket.Utils
open FSharp.Polyfill
Expand Down Expand Up @@ -653,13 +653,13 @@ let safeGetFromUrl (auth:AuthProvider, url : string, contentType : string) = asy

let downloadStringSync (url : string) (client : HttpClient) =
try
client.DownloadString url |> ok
client.DownloadString url |> Ok
with _ ->
DownloadError url |> fail
DownloadError url |> Error

let downloadFileSync (url : string) (fileName : string) (client : HttpClient) =
tracefn "Downloading file from %s to %s" url fileName
try
client.DownloadFile(url, fileName) |> ok
client.DownloadFile(url, fileName) |> Ok
with _ ->
DownloadError url |> fail
DownloadError url |> Error
32 changes: 22 additions & 10 deletions src/Paket.Core/Common/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open System.Text
open Paket
open Paket.Logging
open Paket.Constants
open Chessie.ErrorHandling
open FsToolkit.ErrorHandling
open Paket.Domain

open System.Threading
Expand Down Expand Up @@ -167,9 +167,9 @@ let createDir path =
try
let dir = DirectoryInfo path
if not dir.Exists then dir.Create()
ok ()
Ok ()
with _ ->
DirectoryCreateError path |> fail
DirectoryCreateError path |> Error

let rec emptyDir (dirInfo:DirectoryInfo) =
if dirInfo.Exists then
Expand Down Expand Up @@ -355,9 +355,9 @@ let saveNormalizedXml (fileName:string) (doc:XmlDocument) =
try
use fstream = File.Create(fileName)
use xmlTextWriter = XmlWriter.Create(fstream, settings)
doc.WriteTo(xmlTextWriter) |> ok
doc.WriteTo(xmlTextWriter) |> Ok
with _ ->
FileSaveError fileName |> fail
FileSaveError fileName |> Error

let mutable autoAnswer = None
let readAnswer() =
Expand Down Expand Up @@ -681,18 +681,18 @@ let parseKeyValuePairs (s:string) : Dictionary<string,string> =
let saveFile (fileName : string) (contents : string) =
verbosefn "Saving file %s" fileName
try
File.WriteAllText (fileName, contents) |> ok
File.WriteAllText (fileName, contents) |> Ok
with _ ->
FileSaveError fileName |> fail
FileSaveError fileName |> Error

let removeFile (fileName : string) =
if File.Exists fileName then
tracefn "Removing file %s" fileName
try
File.Delete fileName |> ok
File.Delete fileName |> Ok
with _ ->
FileDeleteError fileName |> fail
else ok ()
FileDeleteError fileName |> Error
else Ok ()

let normalizeLineEndings (text : string) =
text.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", Environment.NewLine)
Expand Down Expand Up @@ -939,3 +939,15 @@ module Task =

let Map<'TIn,'TOut> (mapper : 'TIn -> 'TOut) (t:Task<'TIn>) : Task<'TOut> =
t.ContinueWith (fun (t:Task<'TIn>) -> mapper(t.Result))

[<RequireQualifiedAccess>]
module Result =

let returnOrFail =
function
| Ok x -> x
| Error errors ->
errors
|> Seq.map (sprintf "%O")
|> String.concat (Environment.NewLine + "\t")
|> failwith
13 changes: 10 additions & 3 deletions src/Paket.Core/Installation/InstallProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module Paket.InstallProcess

open Paket
open Chessie.ErrorHandling
open FsToolkit.ErrorHandling
open Paket.Domain
open Paket.Logging
open Paket.BindingRedirects
Expand Down Expand Up @@ -624,9 +624,16 @@ let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile
with
| _ -> ()

/// Installs all packages from the lock file.
let Install(options : InstallerOptions, forceTouch, dependenciesFile, lockFile : LockFile, updatedGroups, touchedPackages) =
let root = FileInfo(lockFile.FileName).Directory.FullName

let projects = RestoreProcess.findAllReferencesFiles root |> returnOrFail
let projects =
match RestoreProcess.findAllReferencesFiles root with
| Ok x -> x
| Error msgs ->
msgs
|> Seq.map (sprintf "%O")
|> String.concat (Environment.NewLine + "\t")
|> failwithf "Error while finding references files: %s"

InstallIntoProjects(options, forceTouch, dependenciesFile, lockFile, projects, updatedGroups,touchedPackages)
20 changes: 14 additions & 6 deletions src/Paket.Core/Installation/RestoreProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ open Paket.Logging
open Paket.PackageResolver
open Paket.PackageSources
open System
open Chessie.ErrorHandling
open FsToolkit.ErrorHandling
open System.Reflection
open Requirements

Expand Down Expand Up @@ -174,15 +174,16 @@ let findAllReferencesFiles root =
match p.FindReferencesFile() with
| Some fileName ->
try
Some(ok (p, ReferencesFile.FromFile fileName))
Some(Ok (p, ReferencesFile.FromFile fileName))
with e ->
Some(fail (ReferencesFileParseError (FileInfo fileName, e)))
Some(Error (ReferencesFileParseError (FileInfo fileName, e)))
| None ->
None

ProjectFile.FindAllProjects root
|> Array.choose findRefFile
|> collect
|> Array.toList
|> List.sequenceResultA

let copiedElements = ref false

Expand Down Expand Up @@ -708,8 +709,15 @@ let Restore(dependenciesFileName,projectFile:RestoreProjectOptions,force,group,i
lockFile,lazy LocalFile.empty,false
else
let localFile =
lazy (LocalFile.readFile localFileName.FullName
|> returnOrFail)
lazy (
match LocalFile.readFile localFileName.FullName with
| Ok x -> x
| Error errors ->
errors
|> Seq.map (sprintf "%O")
|> String.concat (Environment.NewLine + "\t")
|> failwith
)
lazy LocalFile.overrideLockFile localFile.Value lockFile.Value,localFile,true

// Shortcut if we already restored before
Expand Down
6 changes: 3 additions & 3 deletions src/Paket.Core/Installation/UpdateProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open Paket
open System.IO
open Paket.Domain
open Paket.PackageResolver
open Chessie.ErrorHandling
open FsToolkit.ErrorHandling
open Paket.Logging

let selectiveUpdate force getSha1 getVersionsF getPackageDetailsF getRuntimeGraphFromPackage (lockFile:LockFile) (dependenciesFile:DependenciesFile) updateMode semVerUpdateMode =
Expand Down Expand Up @@ -179,7 +179,7 @@ let detectProjectFrameworksForDependenciesFile (dependenciesFile:DependenciesFil
let groups =
let targetFrameworks = lazy (
let rawRestrictions =
RestoreProcess.findAllReferencesFiles root |> returnOrFail
RestoreProcess.findAllReferencesFiles root |> Result.returnOrFail
|> List.collect (fun (p,_) ->
p.GetTargetProfiles()
|> List.map Requirements.FrameworkRestriction.ExactlyPlatform)
Expand Down Expand Up @@ -280,7 +280,7 @@ let SmartInstall(dependenciesFile:DependenciesFile, updateMode, options : Update
let lockFile,hasChanged,updatedGroups,touchedPackages = SelectiveUpdate(dependenciesFile, options.Common.AlternativeProjectRoot, updateMode, options.Common.SemVerUpdateMode, options.Common.Force)

let root = Path.GetDirectoryName dependenciesFile.FileName
let projectsAndReferences = RestoreProcess.findAllReferencesFiles root |> returnOrFail
let projectsAndReferences = RestoreProcess.findAllReferencesFiles root |> Result.returnOrFail

if not options.NoInstall then
tracefn "Installing into projects:"
Expand Down
36 changes: 18 additions & 18 deletions src/Paket.Core/PackageAnalysis/Environment.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

open System.IO

open Chessie.ErrorHandling
open FsToolkit.ErrorHandling
open Paket.Domain
open InstallProcess

Expand All @@ -21,29 +21,29 @@ module PaketEnv =
LockFile = lockFile
Projects = projects }

let fromRootDirectory (directory : DirectoryInfo) = trial {
let fromRootDirectory (directory : DirectoryInfo) = validation {
if not directory.Exists then
return! fail (DirectoryDoesntExist directory)
return! Error (DirectoryDoesntExist directory)
else
let! dependenciesFile =
let fi = FileInfo(Path.Combine(directory.FullName, Constants.DependenciesFileName))
if not fi.Exists then
fail (DependenciesFileNotFoundInDir directory)
Error (DependenciesFileNotFoundInDir directory)
else
try
ok (DependenciesFile.ReadFromFile(fi.FullName))
Ok (DependenciesFile.ReadFromFile(fi.FullName))
with e ->
DependenciesFileParseError(fi,e) |> fail
DependenciesFileParseError(fi,e) |> Error

let! lockFile =
let fi = FileInfo(Path.Combine(directory.FullName, Constants.LockFileName))
if not fi.Exists then
None |> ok
None |> Ok
else
try
LockFile.LoadFrom(fi.FullName) |> Some |> ok
LockFile.LoadFrom(fi.FullName) |> Some |> Ok
with _ ->
fail (LockFileParseError fi)
Error (LockFileParseError fi)

let! projects = RestoreProcess.findAllReferencesFiles(directory.FullName)

Expand All @@ -63,29 +63,29 @@ module PaketEnv =

let ensureNotExists (directory : DirectoryInfo) =
match fromRootDirectory directory with
| Result.Ok _ -> fail (PaketEnvAlreadyExistsInDirectory directory)
| Result.Bad(msgs) ->
| Ok _ -> Error [PaketEnvAlreadyExistsInDirectory directory]
| Error errors ->
let filtered =
msgs
errors
|> List.filter (function
| DependenciesFileNotFoundInDir _ -> false
| _ -> true )
if filtered |> List.isEmpty then ok directory
else Result.Bad filtered
if filtered |> List.isEmpty then Ok directory
else Error filtered

let ensureNotInStrictMode environment =
if not environment.DependenciesFile.Groups.[Constants.MainDependencyGroup].Options.Strict then ok environment
else fail StrictModeDetected
if not environment.DependenciesFile.Groups.[Constants.MainDependencyGroup].Options.Strict then Ok environment
else Error StrictModeDetected

let ensureLockFileExists environment =
environment.LockFile
|> failIfNone (LockFileNotFound environment.RootDirectory)
|> Result.requireSome (LockFileNotFound environment.RootDirectory)

let initWithContent sources additional (directory : DirectoryInfo) =
match locatePaketRootDirectory directory with
| Some rootDirectory when rootDirectory.FullName = directory.FullName ->
Logging.tracefn "Paket is already initialized in %s" rootDirectory.FullName
ok ()
Ok ()
| _ ->
let sourcesSerialized =
(sources
Expand Down
6 changes: 3 additions & 3 deletions src/Paket.Core/PackageAnalysis/FindOutdated.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Paket.FindOutdated

open Paket.Domain
open Paket.Logging
open Chessie.ErrorHandling
open FsToolkit.ErrorHandling
open System.IO

let private adjustVersionRequirements strict includingPrereleases (dependenciesFile: DependenciesFile) =
Expand All @@ -25,7 +25,7 @@ let private adjustVersionRequirements strict includingPrereleases (dependenciesF
DependenciesFile(dependenciesFile.FileName, groups, dependenciesFile.Lines)

/// Finds all outdated packages.
let FindOutdated strict force includingPrereleases groupNameFilter environment = trial {
let FindOutdated strict force includingPrereleases groupNameFilter environment = result {
let! lockFile = environment |> PaketEnv.ensureLockFileExists

let dependenciesFile =
Expand Down Expand Up @@ -82,7 +82,7 @@ let private printOutdated changed =
tracefn " * %O %O -> %O" packageName oldVersion newVersion

/// Prints all outdated packages.
let ShowOutdated strict force includingPrereleases groupName environment = trial {
let ShowOutdated strict force includingPrereleases groupName environment = result {
let! allOutdated = FindOutdated strict force includingPrereleases groupName environment
printOutdated allOutdated
}
Loading