-
Notifications
You must be signed in to change notification settings - Fork 255
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
Clearing an specific package from NuGet cache - Mini spec #10427
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Interested in the VS option down the road
@@ -0,0 +1,92 @@ | |||
# Clearing an specific package from NuGet cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a cache, it's an installation directory. There's no updating, stale checks etc.
It's like program files.
Please refer to it as global packages folder
.
* Status: **Incubating** | ||
* Author(s): [Fernando Aguilar](https://github.com/dominofire) | ||
|
||
The purpose is to add a feature to `nuget locals` command to delete a package from NuGet cache folder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose is to add a feature to `nuget locals` command to delete a package from NuGet cache folder | |
The purpose is to add a feature to `nuget locals` command to delete a package from NuGet global packages folder folder |
|
||
## Problem Background | ||
|
||
There's some interest on having features to delete an specific package instead of clearing the whole cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some interest on having features to delete an specific package instead of clearing the whole cache. | |
There's some interest on having features to delete an specific package instead of clearing the whole global packages folder. |
## Non-Goals | ||
|
||
- Cache expiration policies are not covered | ||
- Deleting cached packages from an specific folder are not covered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on this?
|
||
## Goals | ||
|
||
- Add command options to `dotnet nuget locals` to delete _one_ package from a NuGet cache folder, either _one_ or multiple versions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add command options to `dotnet nuget locals` to delete _one_ package from a NuGet cache folder, either _one_ or multiple versions. | |
- Add command options to `dotnet nuget locals` to delete _one_ package from a NuGet global packages folder, either _one_ or multiple versions. |
|
||
From ideas described in [this comment](https://github.com/NuGet/Home/issues/5713#issuecomment-320560636), the following command options will delete an specific package. Exmples are listed below. | ||
|
||
Delete a package from cache with an specific version: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete a package from cache with an specific version: | |
Delete a package from the global packages folder with a specific version: |
Delete all versions of multiple packages: | ||
|
||
``` | ||
dotnet nuget locals http-cache --clear --package a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an explicit ask for the http-cache scenarios?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - I need that!
I find that after pushing new packages, then building requiring the new version of the package, it fails as it gets the info for that package from the cache.
It should really flush the package from the cache when pushing automatically.
dotnet nuget locals global-packages --clear --package a --version 1.3 | ||
``` | ||
|
||
Delete all package versions from cache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete all package versions from cache: | |
Delete all package versions from global packages folder: |
Delete all versions of multiple packages (version 2): | ||
|
||
``` | ||
dotnet nuget locals global-packages -clear -packages a,b,c,d,e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach adopted by other commands is multiple arguments instead of ,
delimited values.
Take dotnet restore --source
for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meant to request changes. Apologies for the long overdue review.
|
||
In PackageReference world, the global packages folders are shared across all restored projects. | ||
|
||
There's no current API or command to delete an specific package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no API to do it in a single call, but it's absolutely possible to chain together a few API calls to get the global packages folder from config, create a path resolver for that global packages folder, find the directory for a package, and then delete it.
Given this is the "problem background" section, it makes it sound like this is a problem (and neither the goals or non-goals sections below say whether this is in-scope of this design or not). I don't remember seeing any customers asking for an easier API in the NuGet SDK, so I suggest removing the mention of API here.
Delete all versions of multiple packages (version 2): | ||
|
||
``` | ||
dotnet nuget locals global-packages -clear -packages a,b,c,d,e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other examples have used double dash --clear
and --package
, rather than single dash -clear
and -packages
.
The dotnet CLI uses the GNU argument syntax where only single character arguments use a single dash and any multi-character argument must use double dash. I don't know if the dotnet CLI implements it, but programs using GNU's getopt
treat single dash -ab
the same as two arguments -a -b
, which is why git clean -xdf
is the same as git clean -x -d -f
, but different to git clean --xdf
Delete all versions of multiple packages (version 2): | ||
|
||
``` | ||
dotnet nuget locals global-packages -clear -packages a,b,c,d,e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that --version
is only valid with --package
and not --packages
? Should this be mentioned explicitly?
If it is valid, what's the expected behaviour? Is it possible to specify both multiple packages and multiple versions?
If we don't have customers asking to be able to delete multiple packages in a single command, I suggest it's better to drop this feature, and wait for customer feedback, with information to help us understand why it's difficult to delete one package at a time, like your example above. We can add features/arguments, but removing them is a breaking change, so much more difficult.
@dominoFire Can you assign appropriate reviewers & when you feel comfortable with merging this PR, go ahead and merge? I'm working to clear out stale PRs & this one has sat for some time. |
Team Review: Closing stale PRs, please feel free to re-open when this work continues |
Mini spec for deleting a single package from cache.
This specs cover a part of the design described in #5713