3

My goal is to publish and install my .nupkg to a local package source before I push them to our shared package source.

For this I have created a local directory C:\Users\Public\Documents\Dev\_local-nuget-package-source from which I want to install the compiled .nupkg in another project. I add the .nupkg files as described per Microsoft docs without issues: https://learn.microsoft.com/en-us/nuget/hosting-packages/local-feeds.

However when I try to add the directory as a local source in Visual Studio 2022 > Tools > Options > NuGet Package Manager > Package Sources and try to install a package via the in-built NuGet Package Browser it shows me the following error: enter image description here

And trying to do it via the Package Manager console or nuget in powershell I get an error like: enter image description here

I have checked that all the paths are correct. I have made sure my nuspec files and meta data seem in order. Dis- and re-enable my package source. Clear NuGet Caches. System Restart. Deleting all bin/ and obj/ inside my solution and rebuild. As many related Stack-Overflow and other Forums have suggested.

I am honestly at a loss as to what I am supposed to do to make this work.

1 Answer 1

8

So this took me a while to figure out. Apparently the UI of VS-2022 doesn't add the local package source correctly, which is why it fails.

The solution in the end was to go edit the %AppData%\NuGet\NuGet.config file and change the protocolVersion-attribute of my local source to 2.

After that my package showed up in the NuGet Package Browser, and I was able to install it without issues.

The final package source in NuGet.config would look like this:

<packageSources>
  ...
  <add key="local-nuget-source" value="C:\Users\Public\Documents\Dev\_local-nuget-package-source" protocolVersion="2" />
  ...
</packageSources>
Sign up to request clarification or add additional context in comments.

2 Comments

Actually I just tested wether the attribute protocolVersion is even necessary. And it works even without that attribute. So now the package source looks like: <add key="local-nuget-source" value="C:\Users\Public\Documents\Dev\_local-nuget-package-source" />
Thanks a lot dude. This really helped!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.