Skip to content

Conversation

Numpsy
Copy link
Contributor

@Numpsy Numpsy commented Jun 25, 2025

… packages folder

refs
#3853
#4209

I don't know the history of things in this area, I just hit #3853 when building some things that use paket on a system that has the globalPackagesFolder setting set to a custom location (on a different drive than the default user profile directory) and wondered if it would be possible to fix it by using the 'where is the cache folder' functionality in NuGet.Configuration rather than doing it locally (it contains the logic to look for NUGET_PACKAGES, then globalPackagesFolder, then the regular defaults)

@baronfel
Copy link
Contributor

Definitely highly in favor of using NuGet'a apis to interface with parts of the system that they directly control. Love to see more of this.

@smoothdeveloper
Copy link
Contributor

Giving a look at https://github.com/fsprojects/Paket/issues?q=NUGET_PACKAGES and places in the repository that mentions this environment variable maybe a small safety measure, to know how bad changing things would break.

I get the feeling NUGET_PACKAGES not being used anymore will break people, and maybe some CI users.

But conceptually, using another folder than the one nuget client uses, seems counter-natural, in today's environment.

Could we add an entry in release notes, IIUC, that mentions that this environment variable is not used anymore and that it will leverage the ambient nuget environment instead?

@Numpsy
Copy link
Contributor Author

Numpsy commented Jun 25, 2025

Nuget.Configuration reads NUGET_PACKAGES itself - https://github.com/NuGet/NuGet.Client/blob/d525b0e670f3b6cbd5c73a35f04730a9f658c852/src/NuGet.Core/NuGet.Configuration/Utility/SettingsUtility.cs#L231 - it uses that if set and then tries globalPackagesFolder if it isn't

@Numpsy Numpsy changed the title [Testing] Use NuGet.Configuration to get the path to the NuGet global… Use NuGet.Configuration to get the path to the NuGet global… Aug 3, 2025
@Numpsy Numpsy marked this pull request as ready for review August 3, 2025 10:23
@Numpsy
Copy link
Contributor Author

Numpsy commented Aug 3, 2025

This works for me when doing local builds of FAKE anyway -

  • With a plain restore, it puts the packages in the cache path configured for my user
  • If I set NUGET_PACKAGES to a custom path before doing a restore, the packages get put in that folder

@@ -114,12 +114,9 @@ let GitRepoCacheFolder = Path.Combine(LocalRootForTempData,".paket","git","db")
let [<Literal>] GlobalPackagesFolderEnvironmentKey = "NUGET_PACKAGES"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets referenced from

let _ = directPaketInPathExWithEnv "restore" (scenarioTempPath "extracted-package-permissions") [Paket.Constants.GlobalPackagesFolderEnvironmentKey, localNugetDir]
so I suppose removing that would be a breaking change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants