What is the Microsoft.AspNetCore metapackage?
One of the packages added to many ASP.NET Core templates is Microsoft.AspNetCore. This post takes a quick look at that package and what it contains.
The Microsoft.AspNetCore package is often included as one of the standard project dependencies when starting a new ASP.NET Core project. It provides many of the packages necessary to stand up a basic ASP.NET Core application.
However this package does not contain any actual code or dlls itself. Instead, it simply contains a series of dependencies on other packages. By adding the package to your project you bring in all the packages it depends on, along with their dlls. This is called a metapackage.
You can see this for yourself by downloading the package and taking a look inside. Nupkg files are essentially just zip files, so you can download them and open them up. Just change the file extension to zip and open in Windows Explorer, or open them with your archive browser of choice:
As you can see, there's really not a lot of files inside. The main one you can see is the Microsoft.AspNetCore.nuspec. This contains the metadata details for the package, including all the package dependencies (you can also see the dependencies listed on nuget.org.
Specifically, the packages it lists are:
Which versions of these packages you will receive depends on which version of the Microsoft.AspNetCore package you install. If you are working on the 'LTS' release version of ASP.NET Core, you will (currently) need the 1.0.4 version of the package. If on the 'Current' release version, you will want version 1.1.1
These dependencies provide the initial basic libraries for setting up a basic ASP.NET Core server that uses the Kestrel web server and includes IIS Integration.
In terms of the application itself, with this package alone you can load application settings and environment variables into configuration, use the
IOptions interface, and configure logging to the console.
For middleware, only the Microsoft.AspNetCore.Diagnostics package is included, which would allow adding middleware such as the
DeveloperExceptionPageMiddleware and the
As you can see, the meta package is generally not sufficient by itself to build a complete application. You would typically use at least the Microsoft.AspNetCore.Mvc or Microsoft.AspNetCore.MvcCore package to add MVC capabilities to your application, and would often need a variety of other packages.
The meta package is a trade off between trying to find a useful collection of packages, that are applicable to a wide range of applications, without bringing in a whole load of dependencies to projects that don't need them. It mostly just serves to reduce the number of explicit dependencies you need to add to your .csproj file. Obviously, as the metapackage takes dependencies on other packages it doesn't reduce the actual dependencies of your project, just how many of them are listed in the project file.
One of the dependencies on which the Microsoft.AspNetCore depends is the NETStandard.Library package, which is itself a metapackage. As that package is a bit complex, I'll discuss it in more detail in a follow up post.