Skip to content

Do not automatically add nuget.org as a package source when it is absent from nuget.config Fixes #44312#45410

Merged
Forgind merged 4 commits intodotnet:release/9.0.2xxfrom
Forgind:warn-for-unexpected-nuget
Dec 19, 2024
Merged

Do not automatically add nuget.org as a package source when it is absent from nuget.config Fixes #44312#45410
Forgind merged 4 commits intodotnet:release/9.0.2xxfrom
Forgind:warn-for-unexpected-nuget

Conversation

@Forgind
Copy link
Contributor

@Forgind Forgind commented Dec 11, 2024

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.

image

image

(Neither command implicitly went to nuget.org.)

Comment on lines 199 to 202
<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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Forgind Forgind merged commit 20ac0a6 into dotnet:release/9.0.2xx Dec 19, 2024
@Forgind Forgind deleted the warn-for-unexpected-nuget branch December 19, 2024 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Templates untriaged Request triage from a team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants