diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3b8179d538..1dac4a3c26 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,4 +1,4 @@ -#### 7.0.0-alpha010 - 2022-12-07 +#### 7.0.0-alpha011 - 2022-12-07 * Support as .NET 6.0 tool * Auto-Restore after paket install an paket update diff --git a/src/Paket.Core/Common/Utils.fs b/src/Paket.Core/Common/Utils.fs index a303a9b583..deaa2d0b0f 100644 --- a/src/Paket.Core/Common/Utils.fs +++ b/src/Paket.Core/Common/Utils.fs @@ -451,8 +451,19 @@ type PackagesFolderGroupConfig = parentPath () |> ResolvedPackagesFolder.ResolvedFolder static member Default = DefaultPackagesFolder - -let RunInLockedAccessMode(lockedFolder,action) = +let runDotnet arguments = + let result = + let p = new System.Diagnostics.Process() + p.StartInfo.FileName <- "dotnet" + p.StartInfo.Arguments <- arguments + p.Start() |> ignore + p.WaitForExit() + p.ExitCode + + if result <> 0 then + failwithf "dotnet %s failed" arguments + +let RunInLockedAccessMode(lockedFolder,lockedAction: unit -> bool) = if not (Directory.Exists lockedFolder) then Directory.CreateDirectory lockedFolder |> ignore @@ -523,10 +534,12 @@ let RunInLockedAccessMode(lockedFolder,action) = try acquireLock DateTime.Now (TimeSpan.FromMinutes 10.) 100 - let result = action() + let runDotNetRestore = lockedAction() releaseLock 5 - result + if runDotNetRestore then + tracefn "Calling dotnet restore" + runDotnet "restore" with | _ -> releaseLock 5 diff --git a/src/Paket.Core/Installation/RestoreProcess.fs b/src/Paket.Core/Installation/RestoreProcess.fs index 2ec058c7f1..6a982115cf 100644 --- a/src/Paket.Core/Installation/RestoreProcess.fs +++ b/src/Paket.Core/Installation/RestoreProcess.fs @@ -594,14 +594,15 @@ let RestoreNewSdkProject lockFile resolved groups (projectFile:ProjectFile) targ let projectFileInfo = FileInfo projectFile.FileName let objDirectory = objDirectory(projectFileInfo, outputPath) - RunInLockedAccessMode( + RunInLockedAccessMode ( objDirectory.FullName, (fun () -> createAlternativeNuGetConfig (projectFileInfo, objDirectory) - createProjectReferencesFiles lockFile projectFile referencesFile resolved groups targetFrameworks objDirectory - referencesFile + createProjectReferencesFiles lockFile projectFile referencesFile resolved groups targetFrameworks objDirectory + false ) - ) + ) + referencesFile let internal getStringHash (s:string) = use sha256 = System.Security.Cryptography.SHA256.Create() @@ -856,6 +857,7 @@ let Restore(dependenciesFileName,projectFile:RestoreProjectOptions,force,group,i let updatedCache, cache, lockFileHash, canEarlyExit = readCache() if canEarlyExit then tracefn "The last restore was successful. Nothing left to do." + false else if verbose then verbosefn "Checking if restore hash is up-to-date" @@ -882,5 +884,7 @@ let Restore(dependenciesFileName,projectFile:RestoreProjectOptions,force,group,i let restoreCacheFile = Path.Combine(root, Constants.PaketRestoreHashFilePath) writeRestoreCache restoreCacheFile updatedCache writeGitignore restoreCacheFile - | None -> ()) + | None -> + () + false) ) diff --git a/src/Paket.Core/Installation/UpdateProcess.fs b/src/Paket.Core/Installation/UpdateProcess.fs index 5c903f2855..f1073d55d7 100644 --- a/src/Paket.Core/Installation/UpdateProcess.fs +++ b/src/Paket.Core/Installation/UpdateProcess.fs @@ -231,18 +231,6 @@ let SelectiveUpdate(dependenciesFile : DependenciesFile, alternativeProjectRoot, let hasChanged = lockFile.Save() lockFile,hasChanged,updatedGroups -let runDotnet arguments = - let result = - let p = new System.Diagnostics.Process() - p.StartInfo.FileName <- "dotnet" - p.StartInfo.Arguments <- arguments - p.Start() |> ignore - p.WaitForExit() - p.ExitCode - - if result <> 0 then - failwithf "dotnet %s failed" arguments - /// Smart install command let SmartInstall(dependenciesFile:DependenciesFile, updateMode, options : UpdaterOptions) = let lockFile,hasChanged,updatedGroups = SelectiveUpdate(dependenciesFile, options.Common.AlternativeProjectRoot, updateMode, options.Common.SemVerUpdateMode, options.Common.Force) @@ -279,16 +267,14 @@ let SmartInstall(dependenciesFile:DependenciesFile, updateMode, options : Update let scripts = LoadingScripts.ScriptGeneration.constructScriptsFromData depCache groupsToGenerate options.Common.ProvidedFrameworks options.Common.ProvidedScriptTypes for script in scripts do script.Save rootDir - + + let mutable runDotNetRestore = false if not options.NoInstall then - let mutable runDotNetRestore = false for project, _ in projectsAndReferences do let toolsVersion = project.GetToolsVersion() if toolsVersion >= 15.0 then runDotNetRestore <- true - if runDotNetRestore then - tracefn "Calling dotnet restore" - runDotnet "restore" + runDotNetRestore /// Update a single package command let UpdatePackage(dependenciesFileName, groupName, packageName : PackageName, newVersion, options : UpdaterOptions) = diff --git a/src/Paket.Core/PackageManagement/AddProcess.fs b/src/Paket.Core/PackageManagement/AddProcess.fs index 0e4a1c34aa..a0a1b93dcd 100644 --- a/src/Paket.Core/PackageManagement/AddProcess.fs +++ b/src/Paket.Core/PackageManagement/AddProcess.fs @@ -83,6 +83,7 @@ let private add installToProjects addToProjectsF dependenciesFileName groupName tracefn "Resolved package '%s' to version %s" package.Name resolved.Version.AsString | None -> traceWarnfn "Could not find package %s in group %s" package.Name groupName.Name + installAfter // Add a package with the option to add it to a specified project. let AddToProject(dependenciesFileName, groupName, package, version, options : InstallerOptions, projectName, installAfter, runResolver, packageKind) = diff --git a/src/Paket.Core/PackageManagement/RemoveProcess.fs b/src/Paket.Core/PackageManagement/RemoveProcess.fs index d2d18a6e96..7cceb84139 100644 --- a/src/Paket.Core/PackageManagement/RemoveProcess.fs +++ b/src/Paket.Core/PackageManagement/RemoveProcess.fs @@ -48,6 +48,7 @@ let private remove removeFromProjects (dependenciesFileName: string) alternative let updatedGroups = Map.add groupName 0 Map.empty InstallProcess.Install(InstallerOptions.CreateLegacyOptions(force, Requirements.BindingRedirectsSettings.Off, false, false, SemVerUpdateMode.NoRestriction, false, false, [], [], None), false, dependenciesFile, lockFile, updatedGroups) GarbageCollection.CleanUp(dependenciesFile, lockFile) + installAfter /// Removes a package with the option to remove it from a specified project. let RemoveFromProject(dependenciesFileName, groupName, packageName:PackageName, force, projectName, installAfter) = diff --git a/src/Paket.Core/PublicAPI.fs b/src/Paket.Core/PublicAPI.fs index a8d8e054bf..1e7bbf5b41 100644 --- a/src/Paket.Core/PublicAPI.fs +++ b/src/Paket.Core/PublicAPI.fs @@ -35,6 +35,7 @@ type Dependencies(dependenciesFileName: string) = fun () -> emptyDir (Path.Combine(dependencies.RootPath,Constants.DefaultPackagesFolderName)) emptyDir (Path.Combine(dependencies.RootPath,Constants.PaketFilesFolderName)) + false ) emptyDir Constants.UserNuGetPackagesFolder @@ -90,6 +91,7 @@ type Dependencies(dependenciesFileName: string) = fun () -> PaketEnv.init directory |> returnOrFail + false ) #if !NO_BOOTSTRAPPER @@ -106,6 +108,7 @@ type Dependencies(dependenciesFileName: string) = fun () -> PaketEnv.initWithContent sources additional directory |> returnOrFail + false ) #if !NO_BOOTSTRAPPER @@ -138,8 +141,8 @@ type Dependencies(dependenciesFileName: string) = >>= PaketEnv.ensureNotInStrictMode >>= Simplifier.simplify interactive |> returnOrFail - |> Simplifier.updateEnvironment + false ) /// Get path to dependencies file @@ -199,7 +202,7 @@ type Dependencies(dependenciesFileName: string) = RunInLockedAccessMode( Path.Combine(this.RootPath,Constants.PaketFilesFolderName), fun () -> - AddProcess.AddGithub(dependenciesFileName, groupName, repository, file, version, options)) + AddProcess.AddGithub(dependenciesFileName, groupName, repository, file, version, options); false) /// Adds the given git repository to the dependencies file member this.AddGit(groupName, repository) = @@ -214,7 +217,7 @@ type Dependencies(dependenciesFileName: string) = RunInLockedAccessMode( this.RootPath, fun () -> - AddProcess.AddGit(dependenciesFileName, groupName, repository, version, options)) + AddProcess.AddGit(dependenciesFileName, groupName, repository, version, options); false) /// Adds the given package with the given version to the dependencies file. member this.AddToProject(groupName, package: string,version: string,force: bool, withBindingRedirects: bool, cleanBindingRedirects: bool, createNewBindingFiles:bool, projectName: string, installAfter: bool, semVerUpdateMode, touchAffectedRefs): unit = @@ -237,19 +240,19 @@ type Dependencies(dependenciesFileName: string) = member this.AddCredentials(source: string, username: string, password : string, authType : string) : unit = RunInLockedAccessMode( Path.Combine(this.RootPath,Constants.PaketFilesFolderName), - fun () -> ConfigFile.askAndAddAuth source username password authType false |> returnOrFail ) + fun () -> ConfigFile.askAndAddAuth source username password authType false |> returnOrFail; false) /// Adds credentials for a Nuget feed member this.AddCredentials(source: string, username: string, password : string, authType : string, verify : bool) : unit = RunInLockedAccessMode( Path.Combine(this.RootPath,Constants.PaketFilesFolderName), - fun () -> ConfigFile.askAndAddAuth source username password authType verify |> returnOrFail ) + fun () -> ConfigFile.askAndAddAuth source username password authType verify |> returnOrFail; false) /// Adds a token for a source member this.AddToken(source : string, token : string) : unit = RunInLockedAccessMode( Path.Combine(this.RootPath,Constants.PaketFilesFolderName), - fun () -> ConfigFile.AddToken(source, token) |> returnOrFail) + fun () -> ConfigFile.AddToken(source, token) |> returnOrFail; false) /// Installs all dependencies. member this.Install(force: bool) = this.Install(force, false, false, false, false, SemVerUpdateMode.NoRestriction, false, false, [], [], None) @@ -456,20 +459,23 @@ type Dependencies(dependenciesFileName: string) = if paketFileName.Exists then paketFileName.Delete() File.Move(bootStrapperFileName,paketFileName.FullName) + false with - | _ ->()) + | _ -> + false + ) /// Pulls new paket.targets and bootstrapper and puts them into .paket folder. member this.TurnOnAutoRestore(): unit = RunInLockedAccessMode( Path.Combine(this.RootPath,Constants.PaketFilesFolderName), - fun () -> VSIntegration.TurnOnAutoRestore |> this.Process) + fun () -> VSIntegration.TurnOnAutoRestore |> this.Process; false) /// Removes paket.targets file and Import section from project files. member this.TurnOffAutoRestore(): unit = RunInLockedAccessMode( Path.Combine(this.RootPath,Constants.PaketFilesFolderName), - fun () -> VSIntegration.TurnOffAutoRestore |> this.Process) + fun () -> VSIntegration.TurnOffAutoRestore |> this.Process; false) /// Returns the installed version of the given package. member this.GetInstalledVersion(packageName: string): string option =