Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use user NuGet.config, not NUGET_PACKAGES environment variable #4009

Open
nguerrera opened this issue Dec 5, 2024 · 3 comments
Open

Use user NuGet.config, not NUGET_PACKAGES environment variable #4009

nguerrera opened this issue Dec 5, 2024 · 3 comments
Labels
Issue-Bug Something isn't working or needs investigation Needs-Triage New issue that the core contributors need to triage

Comments

@nguerrera
Copy link

nguerrera commented Dec 5, 2024

Dev Home version

0.1901.687.0

Windows build number

No response

Other software

NuGet - all versions

Steps to reproduce the bug

  1. Open Dev Home app
  2. Windows Customization
  3. DevDrive Insights
  4. NuGet Cache (dotnet)
  5. Make the change

Expected result

It changes the global nuget package folder using %APPDATA%\NuGet\NuGet.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
+  <config>
+    <add key="globalPackagesFolder" value="D:\packages\NuGet\cache" />
+  </config>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

Actual result

It changes the package folder using NUGET_PACKAGES environment variable.

The problem with this is that it wins over a repo-local NuGet.config. This is documented and by-design in NuGet.

NuGet/Home#4810 (comment)
https://learn.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders

The environment variable takes precedence over the configuration setting.

I lost nearly a whole day finding this out the hard way.

There are many examples of repos that set globalPackagesFolder in repo-local config and customers could easily get bit too:

https://github.com/search?q=globalPackagesFolder+path%3A**%2Fnuget.config&type=code&ref=advsearch

The documentation should also be fixed here:

https://learn.microsoft.com/en-us/windows/dev-drive/#storing-package-cache-on-dev-drive
MicrosoftDocs/windows-dev-docs#5236

Included System Information

No response

Included Extensions Information

No response

@nguerrera nguerrera added the Issue-Bug Something isn't working or needs investigation label Dec 5, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage New issue that the core contributors need to triage label Dec 5, 2024
@nguerrera
Copy link
Author

cc @nkolev92

@nguerrera nguerrera changed the title Use machine NuGet.config, not NUGET_PACKAGES environment variable Use user NuGet.config, not NUGET_PACKAGES environment variable Dec 8, 2024
@DevTKSS
Copy link

DevTKSS commented Dec 11, 2024

@nguerrera as done just this move and now reading your issue here, please explain this to me (kind of beginner, not done much more with nuget than the visual studio nuget manager (not console)
I recognized more and more my device is getting slower while learning winUI which makes me create new projects, but dont think some CI is really cleaning up unneded stuff... and when seeing two places with same things, this was a sense making step to move the .nuget/packages folder from c: to devdrive...

@nguerrera
Copy link
Author

@DevTKSS This issue is about how to move nuget packages to dev drive. It is not about saying that they shouldn't be moved to dev drive. It is better to use the nuget config file than the NUGET_PACKAGES environment variable for the reasons I outlined in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Something isn't working or needs investigation Needs-Triage New issue that the core contributors need to triage
Projects
None yet
Development

No branches or pull requests

2 participants