Question

In trying to figure out the solution (no pun intended) to this problem: How can I get my Web API app to run again after upgrading to MVC 5 and Web API 2?, I realized that I have sort of brushed aside the relationship between packages and referenced assemblies (haven't given them much thought).

So what is the relationship? I manage packages with NuGet, and I manage assemblies via the context menu beneath the project's References folder, but I see on closer inspection that there seems to be a 1:1 correspondence between some of them.

e.g., I have Entity Framework in my NuGet Package Manager for my project, and I also have an assembly reference to EntityFramework. Yet this is correspondency does not extend across the board.

After all, after selecting the context menu item (I don't know if it's from Visual Studio or Resharper) "Remove Unused References," I have 14 Items referenced; but in the NuGet Package Manager, I have 30 packages listed in the "Installed Packages | All" tableau.

Yet, they all sport a "Manage" button when I highlight them; it seems that in other projects they say "Installed" with a green check mark or something...???

Was it helpful?

Solution

A package consists of 1 or more assemblies. It can also contain other non-assembly (aka, non-dll files), but that's the simple way to look at them.

When you add a "package" to your visual studio project, a few things happen.

  1. Some xml is created saying "This package is a part of this project (csproj for example).
  2. The 1 or more assemblies needed for the package are downloaded locally.
  3. The necessary references are added to your project (csproj for example). This logic is written inside the nuget package. This mimics you doing a "right-click/add reference".
  4. Other things might happen, but the above is the simple version.

A good/quick way to learn about packages is to

Get the MyPackage.nupkg file. Rename the extension....from ".nupkg" to ".zip". And look around the .zip file contents.

You'll see folders like

.\content
.\lib
.\lib\net20
.\lib\net40

and look for some .ps1 files.......and that'll show some voodoo sometimes as well.

That's the simple version. But it'll get you off the ground.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top