From e5b4ea87c329a9dbaca3a22d851d4ca979284308 Mon Sep 17 00:00:00 2001 From: fpellet Date: Sat, 31 Oct 2026 11:02:10 +0100 Subject: [PATCH 1/4] refactor: share the dot folder rule of the searches with findLinkedFolders --- src/Paket.Core/Common/Utils.fs | 14 +++++++++----- src/Paket.Core/PackageManagement/NugetConvert.fs | 2 +- src/Paket.Core/PaketConfigFiles/ProjectFile.fs | 6 ++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Paket.Core/Common/Utils.fs b/src/Paket.Core/Common/Utils.fs index 3d0c953035..9f95b15214 100644 --- a/src/Paket.Core/Common/Utils.fs +++ b/src/Paket.Core/Common/Utils.fs @@ -364,12 +364,16 @@ let isLink (fileSystemInfo: FileSystemInfo) = && fileSystemInfo.Attributes.HasFlag(FileAttributes.ReparsePoint) && (try not (isNull fileSystemInfo.LinkTarget) with _ -> true) -/// Whether a search for project related files should not descend into the directory: its name starts -/// with a dot (e.g. .git, .vs, .localhistory, .devenv), so it is not expected to contain relevant files -/// and can be large or contain unrelated backup/history data (see issue #3250), or it is a link, -/// which may lead out of the folder, or back into it on a cycle +/// Whether the name of the directory starts with a dot (e.g. .git, .vs, .localhistory, .devenv): it is not +/// expected to contain relevant files and can be large or contain unrelated backup/history data (see issue #3250) +let isDotDirectory (directory: DirectoryInfo) = + directory.Name.StartsWith '.' + +/// Whether FindAllFiles and SearchAllProjectRelatedFiles do not descend into the directory: it is a dot directory, +/// or a link, which may lead out of the folder, or back into it on a cycle. +/// SearchAllProjectRelatedFiles skips other directories too, such as packages and node_modules let isSkippedSearchDirectory (directory: DirectoryInfo) = - directory.Name.StartsWith "." || isLink directory + isDotDirectory directory || isLink directory /// Gets all files with the given pattern, skipping the directories for which isSkippedSearchDirectory holds let FindAllFiles(folder, pattern) : FileInfo [] = diff --git a/src/Paket.Core/PackageManagement/NugetConvert.fs b/src/Paket.Core/PackageManagement/NugetConvert.fs index 8eead60c67..c094b3b11b 100644 --- a/src/Paket.Core/PackageManagement/NugetConvert.fs +++ b/src/Paket.Core/PackageManagement/NugetConvert.fs @@ -160,7 +160,7 @@ let private findLinkedFolders (rootDirectory : DirectoryInfo) = let rec linkedFolders (directory : DirectoryInfo) = seq { for subDirectory in directory.GetDirectories() do - if not (subDirectory.Name.StartsWith ".") then + if not (isDotDirectory subDirectory) then if isLink subDirectory then yield subDirectory else yield! linkedFolders subDirectory } diff --git a/src/Paket.Core/PaketConfigFiles/ProjectFile.fs b/src/Paket.Core/PaketConfigFiles/ProjectFile.fs index 2540753128..58570d35ba 100644 --- a/src/Paket.Core/PaketConfigFiles/ProjectFile.fs +++ b/src/Paket.Core/PaketConfigFiles/ProjectFile.fs @@ -1910,8 +1910,10 @@ type ProjectFile with member this.FindOrCreateReferencesFile() = ProjectFile.FindOrCreateReferencesFile (FileInfo this.FileName) - // searches directory and all subdirectories for the search pattern, skipping known problematic directories - // and the ones for which isSkippedSearchDirectory holds + // searches directory and all subdirectories for the search pattern, skipping the ones for which + // isSkippedSearchDirectory holds, as FindAllFiles does, and also the packages and node_modules folders, + // the paket-files folder of the root, the folders with their own paket.dependencies, + // and the Linux system roots when searching from / static member SearchAllProjectRelatedFiles searchPattern folder : FileInfo [] = let paketPath = Path.Combine(folder,Constants.PaketFilesFolderName) |> normalizePath From f9c8cecc64a64ae35a5d1d34436d01717a73b2ef Mon Sep 17 00:00:00 2001 From: fpellet Date: Sat, 31 Oct 2026 11:08:50 +0100 Subject: [PATCH 2/4] refactor: drop the link check project discovery makes dead in convert-from-nuget --- src/Paket.Core/PackageManagement/NugetConvert.fs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Paket.Core/PackageManagement/NugetConvert.fs b/src/Paket.Core/PackageManagement/NugetConvert.fs index c094b3b11b..1d151e4cdf 100644 --- a/src/Paket.Core/PackageManagement/NugetConvert.fs +++ b/src/Paket.Core/PackageManagement/NugetConvert.fs @@ -220,20 +220,13 @@ module NugetEnv = Result.Succeed None |> lift (fun configFile -> (projectFile,configFile)) - // a project reached through a link may be out of the repository, like the files FindAllFiles skips; - // read warns about the folders that are links, so only the project files that are links get a warning - let root = rootDirectory.FullName.TrimEnd(Path.DirectorySeparatorChar) - let rec isBelowLink (directory : DirectoryInfo) = - not (isNull directory) - && directory.FullName.TrimEnd(Path.DirectorySeparatorChar) <> root - && (isLink directory || isBelowLink directory.Parent) - + // FindAllProjects does not descend into the folders that are links, which read warns about, + // so only the project files that are links are left to skip, with a warning let projectFiles = ProjectFile.FindAllProjects rootDirectory.FullName |> Array.filter (fun projectFile -> let file = FileInfo projectFile.FileName - if isBelowLink file.Directory then false - elif isLink file then + if isLink file then traceWarnfn $"%s{file.FullName} is a link: convert-from-nuget leaves it unchanged." false else true) From 5b28c0fdf6f67b852f797ffd00759737b83e120f Mon Sep 17 00:00:00 2001 From: fpellet Date: Sat, 31 Oct 2026 15:31:24 +0100 Subject: [PATCH 3/4] docs: say that Paket skips the dot folders and links when looking for projects --- docs/content/references-files.md | 10 ++++++++++ docs/content/template-files.md | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/docs/content/references-files.md b/docs/content/references-files.md index 370ff63e2d..7214466b2b 100644 --- a/docs/content/references-files.md +++ b/docs/content/references-files.md @@ -22,6 +22,16 @@ differences: Paket looks for `paket.references` files underneath the directory where [`paket.dependencies`](dependencies-file.html) is located. +Paket does not look into the folders whose name starts with a dot, like `.git`, +`.vs` or `.devenv`, nor into the folders that are symbolic links or junctions, +which may lead out of the repository or back into it on a cycle. The projects +there are left out of the commands that look for projects, such as +[`paket install`](paket-install.html), [`paket update`](paket-update.html), +[`paket add`](paket-add.html), [`paket remove`](paket-remove.html), +[`paket convert-from-nuget`](paket-convert-from-nuget.html) and a +[`paket restore`](paket-restore.html) of the whole repository. See the +[`paket.template` files](template-files.html) for `paket pack`. + ## Layout The file whitelists any dependencies from the diff --git a/docs/content/template-files.md b/docs/content/template-files.md index fb5e9f5873..7cd8ebc3ed 100644 --- a/docs/content/template-files.md +++ b/docs/content/template-files.md @@ -11,6 +11,15 @@ possible values: * `project`: Paket will look for a matching project file, and infer dependencies and metadata from the project +`paket pack` looks for the template files in every folder but the `packages` +and `paket-files` folders at the top, including the folders whose name starts +with a dot and the links, so a cyclic link there can keep it from finishing. +It does not look for projects in these folders, though (see +[the `paket.references` files](references-files.html#Location)), so it does not +pack their `project` templates properly: the package gets neither the +assemblies nor the dependencies of the project, and `paket pack` fails when the +folder holds more than one project. Keep such templates out of these folders. + Matching project and template files must be in the same directory. If only one project is in the directory the template file can be called `paket.template`, otherwise the name of the template file must be the name of the project file From c8ab48fecc09b24358d9a5030f5a4a80daa2583d Mon Sep 17 00:00:00 2001 From: fpellet Date: Sat, 31 Oct 2026 15:31:53 +0100 Subject: [PATCH 4/4] docs: correct the release note of the project discovery change --- RELEASE_NOTES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 892cf63044..25818ee772 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,7 +1,8 @@ #### Unreleased * BREAKING: `paket pack --release-notes-file` reads the file with Fake.Core.ReleaseNotes 6, in the formats described in https://fake.build/reference/fake-core-releasenotes.html: the package version is the first word of the latest header that is a whole SemVer version, so `## [1.2.3] - 2020-01-01` and `## v1.2.3 - 2020-01-01` give `2020-01-01`; pass `--version` for such headers. Prerelease versions like `1.2.3-beta.11.2` are no longer cut, and build metadata (`+sha.abc`) is kept - https://github.com/fsprojects/FAKE/pull/2686 -* BREAKING: Paket no longer looks for projects and `paket.template` files in the folders whose name starts with a dot, like `.devenv`, nor in the folders that are links, as `paket convert-from-nuget` already did for the solutions and NuGet files: the projects there are left out of install, restore, update, remove and pack. Until now only `.git` and `.fable` were skipped. A cyclic link, as in a Nix `.devenv` profile, no longer makes the search run forever - https://github.com/fsprojects/Paket/pull/4421 +* BREAKING: Paket no longer looks for projects in the folders whose name starts with a dot, like `.devenv`, nor in the folders that are links, as `paket convert-from-nuget` already did for the solutions and NuGet files: the projects there are left out of install, restore, update, add, remove and convert-from-nuget. `paket pack` still finds the `paket.template` files there, but packs a `project` template without the assemblies and dependencies of its project, and fails when its folder holds more than one project. Until now only `.git` and `.fable` were skipped - https://github.com/fsprojects/Paket/pull/4421 +* Looking for projects no longer runs forever on a cyclic directory link, as in a Nix `.devenv` profile. `paket pack` still follows the links when it looks for template files - https://github.com/fsprojects/Paket/pull/4421 @michaelglass * The warning about the FSharp.Core binding redirects of F# projects links to an existing section of the documentation #### 12.0.0-alpha003 - 2026-10-26