Closed
Description
In .NET Core 2.0, the CLI started shipping a feature that adds an offline package feed called the NuGetFallbackFolder. This adds unnecessary bloat to SDK images in the following ways:
- ~660 MB of xmldocs are stored in
~/.dotnet/NuGetFallbackFolder
. xmldocs are unnecessary in build images. - first run of dotnet-restore creates about 5,700 duplicate files which adds about 326 MB. This duplication is caused by copying files from
~/.dotnet/NuGetFallbackFolder
to~/.nuget/packages
- Any users that build inside the image and don't clear out the
~/.nuget/packages
folder end up with a bloated image. Here is the resulting duplication between the nuget cache and fallback folders:fdupes -r -m ~/.dotnet/NuGetFallbackFolder/ ~/.nuget/packages/ 11439 duplicate files (in 2809 sets), occupying 876.3 megabytes
Suggestions
- Exclude xmldocs from NuGet fallback folder
- Disable the offline package cache feature altogether.
- Warmup the NuGet cache by running dotnet-restore as a part of the image creation.
Or some combination of the ideas above.
Details
How I measured the numbers
Using: microsoft/dotnet-nightly:2.0.0-preview1-sdk
- Measure the effect of a dotnet-restore
- Install fdupes tool.
apt-get update -qq && apt-get install -y fdupes
mkdir /app && cd /app
ls ~/.nuget/
. The~/.nuget/packages/
folder does not yet exist.dotnet new web
(automatically launchesdotnet restore
)fdupes -r -m ~/.dotnet/NuGetFallbackFolder/ ~/.nuget/packages/
- Count files added to nuget cache:
find ~/.nuget/packages -type f | wc -l
- Install fdupes tool.
- Count xmldoc files
find ~/.dotnet -name "*.xml" -type f | wc -l
- Count xmldoc filesize:
find ~/.dotnet/ -name "*.xml" -type f -print0 | du -sb --files0-from=- | awk '{ total += $1} END { print total/1024/1024 }'
(number is in MB)