0

My goal is conveniently adding my own library to my projects within my local network. I put the library in a SMB shared directory.

Get-Package -Source \\my\share\nuget -ListAvailable

showed the package. But when I tried

Install-Package ClassLibrary1 -Source \\my\share\nuget

VS ignored that source because of transient management or something and installed it from nuget.org. I searched the web and found this existing question, but adding that SMB share to VS's source list (after nuget.org) did not work because it still get it from nuget.org. I tried to specify the source like

Install-Package ClassLibrary1 -Source Local

where "Local" was the name I used in VS, but it did not work either. How can I make a local source work within my local network?

enter image description here

Damn Vegetables
  • 11,484
  • 13
  • 80
  • 135

1 Answers1

0

From this link we can see that:

The URL or folder path for the package source to search. Local folder paths can be absolute, or relative to the current folder. If omitted, Install-Package searches the currently selected package source.

\\my\share\nuget is a UNC path. So this path format doesn't work for "-source": enter image description here

You can uncheck nuget.org in package sources, clear the nuget cache and then use this command to install the package.

Jingmiao Xu-MSFT
  • 2,076
  • 1
  • 3
  • 10
  • The MS page only explains "nuget", not VS's PM console, and I thought they were basically the same thing. MS's page had an example like `nuget add new_package.1.0.0.nupkg -source \\myserver\packages`. So, a UNC path be used with "nuget -source", but not with "Install-Package -source"? – Damn Vegetables Nov 24 '22 at 06:20
  • [The nuget command](https://learn.microsoft.com/en-us/nuget/reference/nuget-exe-cli-reference) is different from [the powershell command](https://learn.microsoft.com/en-us/nuget/reference/powershell-reference). VS's PM console use PowerShell command. We can see [this](https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-add)"Specifies the package source, which is a folder or UNC share, to which the nupkg will be added. Http sources are not supported." So I think nuget commands can work with UNC paths but powershell commands can't. – Jingmiao Xu-MSFT Nov 24 '22 at 06:34