Visual Studio For Mac Add Nuget Package

Active1 year, 11 months ago

You can add the directory that contains the.nupkg file as a package source in Visual Studio for Mac. Select Preferences from the main menu. Open NuGet - Sources in the Preferences dialog.

we are playing with Nuget and want to setup a private package source (on an internal webserver). I've followed the following instructions to add it to visual studio - (See package sources) https://docs.nuget.org/consume/Package-Manager-Dialog

I'm wondering if there's a way of scripting this outside Visual studio. (I could automatically add it to VS when I rebuild a new workstation)

  • 2 days ago I have a project and am attempting to install a nugget package, but when I click on Project -> Add Nuget Packages I get this error: [nuget.org] Failed to retrieve metadata from source 'https://api.
  • Even if that was working the Entity Framework NuGet packages that add extra PowerShell commands are going to be Visual Studio on Windows specific and would not work in Visual Studio for Mac.
Ruben Bartelink
46.1k17 gold badges148 silver badges205 bronze badges
LareauLareau
1,5371 gold badge21 silver badges42 bronze badges

3 Answers

NuGet package sources are stored in a NuGet.Config file that can be stored in three different places:

Visual Studio Code Add Nuget

  1. User profile
  2. With the solution itself.
  3. Machine wide in ProgramData: %ProgramData%NuGetConfig*.config

For the user profile the package sources are stored in the file:

When you add the package source in Visual Studio this is where the package source will be saved.

For each solution Visual Studio will look in several directories for the NuGet.Config file before using the one from the user's profile. With a solution in the directory c:ProjectsMySolution then NuGet will look for this file in the directories:

  • c:ProjectsMySolution.nugetnuget.config
  • c:ProjectsMySolutionnuget.config
  • c:Projectsnuget.config
  • c:Projectsnuget.config
  • c:nuget.config

Machine wide package sources are shown in the Machine-wide section of the dialog in Visual Studio. Visual Studio will look in following directories:

  • %programdata%NuGetConfigIDEVersionSKU*.config
  • %programdata%NuGetConfigIDEVersion*.config
  • %programdata%NuGetConfigIDE*.config
  • %programdata%NuGetConfig*.config
  • %ProgramData%NuGetConfigIDE*.config
  • %ProgramData%NuGetConfig*.config

Visual Studio Code Nuget Package

Note that IDE will be replaced with VisualStudio. The Version will be replaced by the Visual Studio version number. The SKU will be replaced with Ultimate, Pro, Professional or Premium.

Visual Studio For Mac Add Nuget Package

To programatically add package sources to an NuGet.Config file you could use NuGet.exe which allows you to add or update package sources using a command line similar to:

Cannot

Or you can use another tool to update the XML in the NuGet.Config file.

Matt WardMatt Ward
40k4 gold badges75 silver badges82 bronze badges

This might help you... talks about configuring NuGet.Targets by default and pushing it to all dev machines...

MaxOvrdrvMaxOvrdrv

Visual Studio For Mac Cannot Add Nuget Package

Visual Studio For Mac Add Nuget Package

Visual Studio For Mac Download

For those who just need to add a package manager to their own development environment: In Visual Studio click Tools | Nuget Package Manager | Package Manager Settings Then under Package Sources you can enter the new source.

Jim BJim B

X Code

Not the answer you're looking for? Browse other questions tagged nugetnuget-package or ask your own question.