Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core and NuGet

I installed .net core from this site. Playing with it led to a number of related package management questions:

  1. The dotnet restore command proceeded to "install" .net core NuGet packages. Where were those packages "installed"? A new folder was not created.
  2. The dotnet restore for the "hello world" minimal example required about a hundred NuGet packages, where 99% were presumably irrelevant to the "hello world" app. Granted, a .net native build will remove all that is not needed - but I expected that the restore also would have grabbed very little (three or four packages, not a hundred). Why this behavior?
  3. I created a second "hello world" project and again ran dotnet restore. This time no packages were installed at all. It seems all the packages installed the first time-around went into some global location to be shared. I thought .Net Core didn't work that way. I thought .Net Core projects kept all their dependencies locally. The only framework I targeted was dnxcore50. Why this behavior?
  4. I would like to "uninstall" all these global packages, and try again (just for learning purposes). How might that be accomplished? Remember, as stated in question #1, I don't know where all those files were installed.
  5. Almost all of the packages installed via the restore command were listed as beta. Odd. I thought .Net Core was in RC1, not beta. Confused by this. Why this behavior?

I'm also curious of what documentation could/would have explained all this to me. I tried googling for each of these questions, and found nothing (perhaps just horrible google-fu?).

like image 666
Brent Arias Avatar asked Feb 04 '16 15:02

Brent Arias


People also ask

Does .NET core use NuGet?

NET (including . NET Core), the Microsoft-supported mechanism for sharing code is NuGet, which defines how packages for .

Where are NuGet packages installed .NET core?

The global-packages folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder.

What is NuGet package in ASP.NET Core?

NuGet is a powerful ecosystem of tools and services. It was introduced in 2010 as an open source package manager for the Microsoft development platform including . NET. NuGet is the easiest way to improve and automate your development practices.


3 Answers

Update:

  1. The nuget packages are installed in a global location. By default it used to be ..\Users\[YourUserFolder]\.dnx\packages but it appeared to have changed to ..\Users\[YourUserFolder]\.nuget\packages

In NuGet 3+, you can use the NuGet CLI's following command to get the global-packages folder location

nuget locals global-packages -list

Check out following links for more details about NuGet

  • http://blog.nuget.org/20151008/NuGet-3-What-and-Why.html

  • https://docs.nuget.org/ndocs/consume-packages/configuring-nuget-behavior

  • https://docs.nuget.org/ndocs/tools/nuget.exe-cli-reference#locals


  1. The default ASP.Net template has so many packages. Since you tried first time, it tried get all those 100s of packages

  2. You already had those packages in your nuget global locations, it skipped the restore.

  3. Delete all contents under packages folder (location indicated in 1)

  4. Some of the beta packages are there. You can go to project.json file (available under the web root) and play with the dependencies section.

like image 185
Vivek N Avatar answered Oct 20 '22 11:10

Vivek N


I just found out that there's another location for NuGet packages used in .NET core projects. Its located at:

C:\Users\[User]\.nuget\packages

I think that this location contains regular .NET Framework packages.

Update: Thanks to brappleye3, here's a link to the documentation regarding dotnet restore.

like image 15
Dibran Avatar answered Oct 20 '22 10:10

Dibran


I'm working with .Net Core 2.x and, I think, NuGet 4.x. Found Package locations here:

C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

like image 2
Jester Avatar answered Oct 20 '22 11:10

Jester