8

I've created a package with nugget CLI but can't find a way to install it from the IDE, the Package Manager Console isn't available in the version for Mac, and the nuget CLI tries to retrieve the package from the internet instead of reading the .nupkg file.

I have VS Community for Mac 7.3.3, mono 5.4.1.7 and nuget 4.3.0.4406

This is what I get when trying to install from the CLI

$ nuget install Package.1.0.0.nupkg 
Feeds used:
  https://api.nuget.org/v3/index.json

  GET https://api.nuget.org/v3/registration3-gz-semver2/package.1.0.0.nupkg/index.json
  NotFound https://api.nuget.org/v3/registration3-gz-semver2/package.1.0.0.nupkg/index.json 363ms
Unable to find package 'Package.1.0.0.nupkg'
Matt Ward
  • 47,057
  • 5
  • 93
  • 94
rraallvv
  • 2,875
  • 6
  • 30
  • 67

2 Answers2

8

You can add the directory that contains the .nupkg file as a package source in Visual Studio for Mac.

  1. Select Preferences from the main menu.
  2. Open NuGet - Sources in the Preferences dialog.
  3. Click the Add button.
  4. In the Add Package Source dialog that opens click the Browse button.
  5. Find the directory with your .nupkg file then click the Open button.
  6. Change the Name of the package source if you want to.
  7. Then click the Add Source button.

Then you should be able to select the package source for your directory in the Add Packages dialog.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • 4
    Don't forget to enable "show pre-release packages" button if you still can't see your .nupkg – Mysterious_android Feb 16 '18 at 04:47
  • 1
    Using this approach, once you deploy your application using a CI solution (e.g. App Center) the nuget package is not found and so the build fails. Looking at the source code changes after adding a local nuget package, it's no surprise, as there is nothing saying where to look for the nuget package (it's purely a Visual Studio preference.) How do we indicate in the csproj file where to look for the nuget package? Otherwise CI builds will always fail. – Justin Jan 08 '20 at 17:24
  • 1
    You can create a NuGet.Config file for the solution. As long as it exists in some folder at or above the sln file then NuGet will find it. Include that NuGet.Config file in source control. That is what we do for VS Mac - https://github.com/mono/monodevelop/blob/master/NuGet.config – Matt Ward Jan 09 '20 at 12:33
2

I understand this is an answered question but for the sake of completeness, I'll add my 2 cents. Since the original question talks about nuget CLI, one can use the CLI to add a package source like so:

nuget sources Add -Name "Feed Name" -Source "/path/to/directory" 
Sudhanshu Mishra
  • 6,523
  • 2
  • 59
  • 76