38

As the title says, why do the ASP.NET MVC 4 projects have soooo many NuGet packages? Is the entire framework split into packages now? Which ones are truly important for an empty project that will be a website, no API, etc?

UPDATE

To clarify, I'm not having issue, well, unless you count basic confusion as one. I just want to know why new MVC 4 projects have so many packages installed by default? An empty project has one full page of packages. An internet project has three full pages of packages.

I'm just curious why this is because my current MVC 3 projects use at max five packages.

Amirhossein Mehrvarzi
  • 18,024
  • 7
  • 45
  • 70
Gup3rSuR4c
  • 9,145
  • 10
  • 68
  • 126
  • I'm curious, why is having a lot of NuGet packages an issue? What problem are you trying to solve? – neontapir Aug 16 '12 at 22:13
  • 3
    I didn't say there was an issue. I simply installed MVC 4 and created a new project and poked around to see what was different. An empty project has one page full of packages, and the internet project has three full pages of packages. I simply want to know why that is because my MVC 3 projects at best use about five packages. Just being curious. – Gup3rSuR4c Aug 16 '12 at 22:17
  • I asked the question because it might color the kind of responses you receive. – neontapir Aug 16 '12 at 22:18
  • 2
    might be better on http://programmers.stackexchange.com? not sure though... – Graham Smith Aug 16 '12 at 22:24
  • 1
    the ASP.net has made it no secret that they want to componentize as much of the frame work which allows them to ship out of band releases to specific parts of the framework with out releasing a full patch or minor release update ie the JSON Framework which moved to JSON.net in MVC 4 can be updated independantly of MVC or they address a bug/security issue in a part of the api without updateing ththe whoile thing this also makes developers lives easier since they only have to update a package instead of a full mvc update on the developer machine and on the server – Chris McGrath Nov 26 '13 at 15:38

2 Answers2

26

As the title says, why do the ASP.NET MVC 4 projects have soooo many NuGet packages?

That's a question you need to ask the designers of the framework.

Which ones are truly important for an empty project that will be a website, no API, etc?

Here's the strict minimum that will allow you to configure routing and define a controller with an action rendering a Razor view:

<packages>
  <package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net40" />
  <package id="Microsoft.AspNet.Razor" version="2.0.20710.0" targetFramework="net40" />
  <package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net40" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
</packages>

or if you prefer only 1/2 of a page:

enter image description here

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • Fair enough I suppose. Thanks for the info. – Gup3rSuR4c Aug 21 '12 at 02:10
  • What about the ASP.NET Web Pages 2 Web Data, Data and Administration? I get it that ASP.NET Web PAges 2 (Core) contains shared MVC and WebForms functionality but what about those three? Are they required or better, what do they contain exactly? – mare Oct 12 '12 at 12:42
  • oh sorry, I now see that ASP.NET Web Helpers brought those in, they are not in the default Basic template. – mare Oct 12 '12 at 12:46
22

ASP.NET MVC has been increasingly delivered via NuGet packages since ASP.NET MVC 3 Tools Update. This offers several advantages:

  • Upgrades to to components delivered via NuGet - MVC itself and other associated components (Razor, Web API) without waiting for a new "big" release of either ASP.NET MVC, .NET, or Visual Studio.
  • This also means that you can use individual parts as you'd like outside of MVC - for instance, Web API can be used outside of ASP.NET.
  • More and more, components are being shared between UI layers and other parts of ASP.NET. Some examples: routing is shared with Web Forms and Web Pages, Razor is shared with Web Pages, the new OAuth parts are shared with Web Forms.

You'll notice that in a project from the Basic template, you'll get the following packages:

  • Microsoft.AspNet.Mvc
  • Microsoft.AspNet.Razor
  • Microsoft.AspNet.WebApi
  • Microsoft.AspNet.WebApi.Client
  • Microsoft.AspNet.WebApi.Core
  • Microsoft.AspNet.WebApi.WebHost
  • Microsoft.AspNet.WebPages
  • Microsoft.Net.Http
  • Microsoft.Web.Infrastructure
  • Newtonsoft.Json

Five of the nine are used for Web Api, which has been highly componentized to allow developers a lot of flexibility about where and how they can use them. If you want to minimize your NuGet packages, you can use the Basic template.

As you move up into the Basic and Internet templates, you'll see more packages to support the additional features the projects provide. Internet brings in several packages of open-source, non-Microsoft code such as OAuth and JavaScript libraries.

There are a lot of JavaScript packages, which is a really good thing when you think about it, since this means that NuGet is automatically handling JavaScript dependencies for you - if you want to upgrade jQueryUI which in turn requires a new version of jQuery, it'll automatically upgrade jQuery for you.

Jon Galloway
  • 52,327
  • 25
  • 125
  • 193
  • Does it mean that I don't have to install ASP.NET MVC4 framework via Web Platform Installer anymore? – Nigiri Aug 28 '13 at 07:01
  • 1
    Visual Studio 2012 includes MVC 4. If you're using 2010, I'd recommend using Web PI for most cases. You could make an MVC 4 site using an empty web application and NuGet packages, but you'd also need to fiddle with web.config, you wouldn't have full VS support for things like snippets, etc. – Jon Galloway Aug 29 '13 at 19:33
  • 3
    Disagree on all the Javascript Nuget packages jammed into the "Empty" MVC projects being a good thing. I don't want to wait to upgrade to the latest patch level of jquery until it's issued over Nuget, which can be as much as a year behind. I'll update it myself - it's a single file, and Nuget is just getting in the way. – Chris Moschini Dec 11 '13 at 16:37
  • To add on the javascript.. I actually hate using nuget packages for something like jquery, angular, bootstrap, etc. I personally think it's bad design to include those in all of your visual studio projects, then host them all at different urls. Especially in multi site/sso systems... Why do people make users download their copy of jquery 12 times browsing their ecosystem? Why don't they have an in house CDN to save user data plans (especially in this new mobile age)... Just my 2 cents, but just cramming nuget packages with copy upon copy of assets like that.. bad code smell. – Ryan Mann Jun 03 '15 at 03:53