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

NoCache option does not work for packages.config based restore/install (GlobalPackagesFolder) #1406

Closed
2 tasks done
zarenner opened this issue Sep 18, 2015 · 11 comments · Fixed by NuGet/NuGet.Client#856
Closed
2 tasks done
Assignees
Labels
help wanted Considered good issues for community contributions. Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:DCR Design Change Request
Milestone

Comments

@zarenner
Copy link

zarenner commented Sep 18, 2015

TODO:
We should probably cover it here in one go - Updated the top comment

  • NoCache should download the package, and store it in the cache
  • NoCaching should download the pacakge but not write it into the cache - Debate the name and the flags before making the change

The NoCache option doesn't work with packages.config based restore or install. The packages are still downloaded to the global package folder, and then copied to the PackagesDirectory.

Also, is %localappdata%\NuGet\Cache used anymore? GetPackageSources still adds it as a source if NoCache isn't specified, but I don't see where anything is ever written to it.

Perhaps this is a gap in my understanding... are %localappdata%\NuGet\Cache ("MachineCache") and %userprofile%.nuget\packages ("GlobalPackagesFolder") meant to do different things? I don't understand why they both exist.

@yishaigalatzer
Copy link

Global packages folder and the cache folders are two different things.

  1. %localappdata%\NuGet\Cache Is a cache - Means you can get packages from there instead of downloading them again. It is off in NuGet3, and we might want to bring it back, we didn't make that determination yet.
  2. %userprofile%.nuget\packages is an install target (or restore target depending who you ask), this is where packages are expanded to, so they get consumed by the projects.

We should revisit this inconsistent state of things and fix it.

My current thoughts are to

  1. Bring back the machine cache either in the %localappdata%\NuGet\Cache or expand the packages to the global path and use that as a cache.
  2. Respect --no-cache for all scenarios

@yishaigalatzer yishaigalatzer added this to the 3.3.0-Beta milestone Sep 18, 2015
@yishaigalatzer yishaigalatzer added the Type:DCR Design Change Request label Sep 18, 2015
@zarenner
Copy link
Author

"expand the packages to the global path and use that as a cache."

Maybe I'm still misunderstanding something - this is the behavior I see. Packages are downloaded to the global path, unpacked there, then copied to [PackagesDirectory]. Restoring the package again into a new directory doesn't re-download the file, it pulls it from the global packages directory. To prove this point - if you add a file into an expanded package in the global packages folder, that file gets copied over if you do a restore into a new PackagesDirectory.

See https://github.com/NuGet/NuGet3/blob/dev/src/NuGet.Protocol.Core.v3/DownloadResourceV3.cs and https://github.com/NuGet/NuGet3/blob/dev/src/NuGet.Protocol.Core.v3/Utility/GlobalPackagesFolderUtility.cs, and https://github.com/NuGet/NuGet3/blob/dev/src/NuGet.Packaging/PackageFolderReader.cs which is used to copy over the expanded package.

Can you please explain what you mean by "this is where packages are expanded to, so they get consumed by the projects"?

@yishaigalatzer
Copy link

It is not a cache, it is used as another package source

Sent from my Windows Phone


From: Zach Rennermailto:[email protected]
Sent: ‎9/‎18/‎2015 2:39 PM
To: NuGet/Homemailto:[email protected]
Cc: Yishai Galatzermailto:[email protected]
Subject: Re: [Home] NoCache option does not work for packages.config based restore/install (GlobalPackagesFolder) (#1406)

"expand the packages to the global path and use that as a cache."

Maybe I'm still misunderstanding something - this is the behavior I see. Packages are downloaded to the global path, unpacked there, then copied to [PackagesDirectory]. Restoring the package again into a new directory doesn't re-download the file, it pulls it from the global packages directory. To prove this point - if you add a file into an expanded package in the global packages folder, that file gets copied over if you do a restore into a new PackagesDirectory.

See https://github.com/NuGet/NuGet3/blob/dev/src/NuGet.Protocol.Core.v3/DownloadResourceV3.cshttps://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fNuGet%2fNuGet3%2fblob%2fdev%2fsrc%2fNuGet.Protocol.Core.v3%2fDownloadResourceV3.cs&data=01%7c01%7cyigalatz%40microsoft.com%7c2843560296bc4e458cf008d2c071b175%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=G6KD%2bGTW3%2bVSK90gZzGa%2fnBxZActBlsb%2fpIxWf6u6rk%3d and https://github.com/NuGet/NuGet3/blob/dev/src/NuGet.Protocol.Core.v3/Utility/GlobalPackagesFolderUtility.cshttps://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fNuGet%2fNuGet3%2fblob%2fdev%2fsrc%2fNuGet.Protocol.Core.v3%2fUtility%2fGlobalPackagesFolderUtility.cs&data=01%7c01%7cyigalatz%40microsoft.com%7c2843560296bc4e458cf008d2c071b175%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=5flXov4naEvMsaNSzthYRr2gNjj6Fix9IEcRyaWb8lw%3d, and https://github.com/NuGet/NuGet3/blob/dev/src/NuGet.Packaging/PackageFolderReader.cshttps://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fNuGet%2fNuGet3%2fblob%2fdev%2fsrc%2fNuGet.Packaging%2fPackageFolderReader.cs&data=01%7c01%7cyigalatz%40microsoft.com%7c2843560296bc4e458cf008d2c071b175%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=1qc5BGs9k3SMRS0q3BOORGaOYobELzu5KxN2nOtZr4A%3d which is used to copy over the expanded package.


Reply to this email directly or view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fNuGet%2fHome%2fissues%2f1406%23issuecomment-141575397&data=01%7c01%7cyigalatz%40microsoft.com%7c2843560296bc4e458cf008d2c071b175%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=FrDJ0AjsMnQgVqFdD0%2bG1PkhSdf5oVlJ%2fWaskxAq6iE%3d.

@yishaigalatzer
Copy link

The -NoCache option is a misnomer, it means always download the packages (but they will still make it into the cache).

Looking at our current backlog, this seems relatively low priority.

@yishaigalatzer yishaigalatzer added the Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. label Oct 1, 2015
@yishaigalatzer yishaigalatzer modified the milestones: 3.3.0-commandline, 3.3.0-Beta Oct 1, 2015
@zjrunner
Copy link

For clarity, are you tracking this workitem to mean -NoCache should download the package each time, but it will not impact expansion into the GlobalPackagesDirectory (profile.nuget) -- that will continue to happen even with -NoCache? Trying to decide if I need to open another workitem to avoid always expanding into GlobalPackagesDirectory or if it is addressed here.

@yishaigalatzer
Copy link

We should probably cover it here in one go - Updated the top comment

  • NoCache should download the package, and store it in the cache
  • NoCaching should download the pacakge but not write it into the cache - Debate the name and the flags before making the change

@yishaigalatzer
Copy link

@emgarten please orchestrate a design review for this ask, so we can end up with a clear behavior document, and tests etc.

@gravidThoughts
Copy link

@yishaigalatzer Is the cli the only client which can use the GlobalPackages directory as a package source?

Also, if it is not a cache, the console messages need to be updated, as the term cache is used.

nuget locals global-packages -clear

Clearing Nuget global packages cache: C:Users\...
Cache cleared.

@yishaigalatzer
Copy link

Everything can use it as a source. But it is indeed not a cache and we should fix the message. Thanks for pointing it out

@pspill
Copy link

pspill commented Jan 26, 2016

On machines with small c: drives, the global-packages folder can become an issue. We are currently seeing build machines with small c: drives and large d: drives running out of space over the course of a month.

@yishaigalatzer
Copy link

@pspill you can configure the global packages folder using NUGET_PACKAGES environment variable. We also support the nuget locals -clear command to automatically do periodic maintenance

@yishaigalatzer yishaigalatzer modified the milestones: 3.4 Beta, 3.4 RTM Feb 25, 2016
@yishaigalatzer yishaigalatzer modified the milestones: 3.4 RTM, 3.4 RTM - Triage, 3.5 Beta Mar 11, 2016
@yishaigalatzer yishaigalatzer modified the milestones: 3.5 Beta, 3.5 RC Apr 8, 2016
@yishaigalatzer yishaigalatzer added the help wanted Considered good issues for community contributions. label Jun 17, 2016
@joelverhagen joelverhagen modified the milestones: 3.6 Beta1, 3.6 Beta2 Sep 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Considered good issues for community contributions. Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:DCR Design Change Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants