Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying the source when adding a nuget package with #r #155

Open
jjavierdguezas opened this issue Jul 21, 2022 · 1 comment
Open
Assignees
Labels
enhancement New feature or request

Comments

@jjavierdguezas
Copy link

jjavierdguezas commented Jul 21, 2022

Feature Description

Context

I tried to add Newtonsoft.Json nuget package using #r "nuget: Newtonsoft.Json" on csharprepl and I got this error:

image

Description

You can have many sources enabled in nuget configuration (you can list them by running nuget sources or dotnet nuget list source commands)

image

but some of them (for example company private package sources) may not be accessible sometimes (authentication or vpn may be needed, etc.).
nuget.org should always be a safe and accessible source, but if the nuget command tries an inaccessible one it fails

I don't know how it works but the nuget add command requires a source as an argument, but the dotnet add package does not, it is optional so I am guessing that it iterates over all sources maybe? I really don't know. I do know that you can enable and disable sources via command line or editing the nuget config xml file, but it is kind of annoying

The error with csharprepl today was because it tried to access my company's private repo and got an auth error

I get the same error when I use dotnet add package command directly:

image

Feature Request

It is possible to extend the #r command to accept a source or do something like --ignore-failed-sources on dotnet restore command?

@jjavierdguezas jjavierdguezas added the enhancement New feature or request label Jul 21, 2022
@waf
Copy link
Owner

waf commented Nov 10, 2022

I spent some time looking into this, and ultimately we're blocked on NuGet/Home#7304 / NuGet/Home#5643. There's a very promising looking SourceCacheContext.IgnoreFailedSources property available to us, but the underlying NuGet APIs don't actually respect it.

A potential workaround (untested) would be to reorder the sources in the NuGet.config file -- from what I can tell they're tried in the same order that they're listed in the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants