1

I developed an asp.net mvc application to manage some business process in our organisation. This application use the following main frameworks :

  • Asp.NET MVC 5.0;
  • Entity framework 6.0 to manage db access;
  • MS Identity 2.0 to manage security : users, roles, access authorizations...;
  • Bootstrap;

I noticed that the packages directory of this solution has become very huge(more than 350 MB). I tried to use the "Remove unused packages" feature of ReShaper but it did not significantly reduce the size of the packages folder. I think that there's some unnecessary packages that must be removed.So, my questions are :

  1. Is it normal to have a packages directory with a size more than 350 MB for a simple asp.net MVC solution ?

  2. How could I reduce the size of this directory and remove all unused and unnecessary packages?

Thanks for your help.

mjwills
  • 23,389
  • 6
  • 40
  • 63
Zakaria.d
  • 158
  • 1
  • 3
  • 16
  • 1
    What actual problem are you having due to the large size? – mjwills Jun 27 '18 at 12:16
  • its okay to have packages size big, I wonder why you want to reduce it? VS will auto restore missing packages if you delete from packages directory – Nitin Sawant Jun 27 '18 at 12:16
  • I just want to have an application whose size is as small as possible. And I noticed that some packages are installed in duplicate (like EntityFramework.6.1.0 and EntityFramework.6.1.3). So, I just wonder if there is some tricks to clean up the "packages" directory. – Zakaria.d Jun 27 '18 at 12:24

3 Answers3

3

Packages included in one of my projects is 450Mb and works as desired and without issues. So I would not be so worried about yours being 350Mb.

If Resharper could not remove any unused packages then it would suggest that they are all being used at some point in your application. How can you find the unused NuGet packages in a solution? was a useful post on Resharpers tool for this.

Note also you can use the Visual Studio Extension ResolveUR - Resolve Unused References

If the packages are being used the project will break when trying to build and the package has been removed.

Fuzzybear
  • 1,388
  • 2
  • 25
  • 42
3

It's 2018, disk space is cheap, 350 MB is not "huge".

There's loads of metadata in those packages, and each package exists as a .nupkg and in extracted form, doubling its size (barring ZIP compression used for packages). So if a package like MVC 5.2 is 300 KB and its extracted size is 1,5 MB, in total that'll already be nearly 2 MB for one package. And you probably have dozens, if not more packages, each taking up their own disk space.

This only becomes a problem when other people on your team upgrade packages and then you pull their version, your packages directory still contains the older versions, as well as the newer versions.

So it can help to regularly clean your packages directory if this happens. Then only the currently used packages will be downloaded again.

Multiple versions of a package installed in a solution also cause older versions to coexist next to newer ones; upgrade all packages for a solution at once ("Manage NuGet Packages for Solution") or consolidate them on the Consolidate tab. This ensures all projects reference the same package version.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
0

I reduced the size considerably with a script that removes languages other than English and things like Android/Xamarin, that I don't use:

FOR /F %%G IN ('DIR packages\ru /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\ja /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\de /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\fr /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\es /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\it /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\ko /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\zh* /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\monoandroid* /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\sl* /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\wp* /B /A:D /S') DO RMDIR /S /Q "%%G"
smirkingman
  • 6,167
  • 4
  • 34
  • 47