Gup3rSuR4c
Gup3rSuR4c

Reputation: 9480

Why does ASP.NET MVC 4 have so many NuGet packages and which are truly important?

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.

Upvotes: 38

Views: 13147

Answers (2)

Jon Galloway
Jon Galloway

Reputation: 53115

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.

Upvotes: 22

Darin Dimitrov
Darin Dimitrov

Reputation: 1038730

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

Upvotes: 26

Related Questions