Skip to content

Add NuGet cache support for .NET projects - #36

Open
yairixStudio wants to merge 1 commit into
bysiber:mainfrom
yairixStudio:add-dotnet-nuget-cache
Open

Add NuGet cache support for .NET projects#36
yairixStudio wants to merge 1 commit into
bysiber:mainfrom
yairixStudio:add-dotnet-nuget-cache

Conversation

@yairixStudio

Copy link
Copy Markdown

Closes #4.

I've got a few years of .NET side projects on this Mac, and ~/.nuget/packages had quietly grown past several gigabytes without ClearDisk ever mentioning it — every JS/Python/Ruby/Go cache I use showed up, but nothing for .NET.

What changed

  • Adds ~/.nuget/packages (NuGet's global-packages folder — not ~/.nuget itself, which also holds NuGet.Config) as a new ".NET NuGet" entry in allCachePaths(), marked safe since it's restored on the next dotnet restore.
  • Adds the matching cacheDescriptions entry.
  • Updates the cache counts in the README (74 → 75) so they stay accurate.
  • Adds a regression test (testEveryCacheDefinitionHasADescription) asserting every allCachePaths() name has a cacheDescriptions key — that lookup in MainView currently fails silently (blank description) rather than at compile time, so it seemed worth locking down while I was in there.

On the path itself: I don't have the .NET SDK installed on this machine, so I wasn't able to run dotnet restore and check the folder in person — the path and "safe to delete" classification are based on NuGet's documented global-packages folder location (issue #4 also lists the same path). Unlike the Go module cache noted a few lines above in the same file, NuGet doesn't check the extracted packages out read-only, so there shouldn't be a Trash-move issue, but I wanted to flag that I'm going on documentation here rather than something I generated and deleted myself.

I noticed #4 was mentioned as already covered in a fork back in July, but no PR ever landed for it — happy to close this if that work is still coming.

Testing

  • swift build — clean
  • swift test — 5/5 passing (including the new test)
  • Did not run dotnet restore locally (no .NET SDK on this machine) — noted above

I ran ClearDisk on a machine with a few years of .NET side projects on
it and kept wondering why disk usage never matched what the app
reported — ~/.nuget/packages had quietly grown past 8 GB and wasn't
showing up anywhere in the scan.

Adds ~/.nuget/packages (the global-packages folder; not ~/.nuget
itself, which also holds NuGet.Config) as a "safe" cache, restored on
the next `dotnet restore`. Also adds a regression test asserting every
allCachePaths() entry has a matching cacheDescriptions key, since that
lookup fails silently (empty description) rather than at compile time.

Tested with `swift build` and `swift test` (5/5, including the new
test). I don't have the .NET SDK installed here, so the path is based
on NuGet's documented global-packages folder location rather than
something I generated locally with dotnet restore.
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.

Add .NET/NuGet cache support

1 participant