Do not automatically add nuget.org as a package source when it is absent from nuget.config Fixes #44312#45410
Conversation
| <data name="NeedNuGetInConfig" xml:space="preserve"> | ||
| <value>The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command.</value> | ||
| <comment>Do not translate 'dotnet tool search' or 'nuget.config'</comment> | ||
| </data> |
There was a problem hiding this comment.
Should we be providing the command for them to add it? I always find it strange to give the user a message to tell them to do something, but not telling them how to do it. Maybe @baronfel has a suggestion.
There was a problem hiding this comment.
The trick is to make sure that we remember to update the message in case the command needed to run ever changes, otherwise we'd be giving incorrect instructions which is just as bad
There was a problem hiding this comment.
Wouldn't it be great if we could just have a command express itself as a string so you could reference it directly in the message? Then, if the command itself changes, the string would update. 😊 (cough my JSON-based parser could do this natively cough)
There was a problem hiding this comment.
For what it's worth, I think this one we could probably do without worrying too much about it changing out from under us, as it's the first example in how to use dotnet nuget add source:
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-add-source#examples
I'll add it provisionally, and if we ultimately decide against it, I can take it out again.
Fixes #44312
If a user doesn't have nuget.org as a source in their nuget.config, we shouldn't assume they want it. This sends a message for dotnet tool search if nuget.org is absent, as it is needed for dotnet tool search to work properly, instead of running the command. For other commands like dotnet new details, it does not automatically add nuget.org to the sources.
(Neither command implicitly went to nuget.org.)