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

dotnet tool install skip unlisted version #28951

Merged
merged 5 commits into from
Aug 1, 2023

Conversation

JiaqiWang18
Copy link
Contributor

@JiaqiWang18 JiaqiWang18 commented Nov 8, 2022

Fixes #24037
Use the NugetToolSearchApiRequest to get the latest listed package version in dotnet tool install <PACKAGE_ID> when --version is not supplied.

Manual Testing

Created a test tool jackywang118.botsay with two versions where the most recent version 2.0.0 is unlisted.
Run dotnet tool install jackywang118.botsay, version 1.0.0 should be installed
A request to https://azuresearch-usnc.nuget.org/query?q=jackywang118.botsay&packageType=dotnettool&semVerLevel=2.0.0 is made to get the most recent listed package version

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@JiaqiWang18
Copy link
Contributor Author

@baronfel

@baronfel
Copy link
Member

This is great! I'd love to see a test validating the behavior though - I think that would require getting known packages with the expected unlisted/listed statuses added to the internal feeds.

Scheduling-wise, @marcpopMSFT this rides the line between a fix and an feature - I think it's what users expect out of NuGet so I'd be happy to see this in 7.0.2xx rather than waiting for 8.0.1xx (which is what main is targeted for).

@JiaqiWang18
Copy link
Contributor Author

This is great! I'd love to see a test validating the behavior though - I think that would require getting known packages with the expected unlisted/listed statuses added to the internal feeds.

Scheduling-wise, @marcpopMSFT this rides the line between a fix and an feature - I think it's what users expect out of NuGet so I'd be happy to see this in 7.0.2xx rather than waiting for 8.0.1xx (which is what main is targeted for).

Thanks for the feedback! Could you point me to where these internal feeds are located? Is there an example test that is using this internal feed you are talking about?

@baronfel
Copy link
Member

The feeds I mention are defined in the nuget.config in the root of the repo, so if you had sample packages that you wanted to use for a test, we could coordinate to get those versions downloaded to an appropriate feed (we have to communicate with an internal team for this), and then your test would be good to go. @dotnet/domestic-cat is this an acceptable plan?

@JiaqiWang18
Copy link
Contributor Author

JiaqiWang18 commented Nov 28, 2022

The feeds I mention are defined in the nuget.config in the root of the repo, so if you had sample packages that you wanted to use for a test, we could coordinate to get those versions downloaded to an appropriate feed (we have to communicate with an internal team for this), and then your test would be good to go. @dotnet/domestic-cat is this an acceptable plan?

I did create this package jackywang118.botsay to test.
It has two versions where 2.0.0 is unlisted and 1.0.0 is not. Maybe this package could be added to the feed so that new test cases can be created under ToolInstallLocalCommandTests and ToolInstallGlobalOrToolPathCommandTests to verify that only 1.0.0 will be installed if running dotnet tool install jackywang118.botsay

@JiaqiWang18
Copy link
Contributor Author

@baronfel sounds like I can't test it by myself. Would it be reasonable to get this PR in and file another issue for the testing part?

@knocte
Copy link

knocte commented Jan 4, 2023

ping? I'm affected by issue #24037 and would prefer this reviewed/merged instead of having to write a workaround.
Thanks!

@baronfel
Copy link
Member

baronfel commented Jan 4, 2023

Thanks for the ping, @knocte - I dropped the ball on this one. Need to get a listed and unlisted package to test with into MS internal feeds, but we can't just take random packages. I'll pick this up again and work with the internal team to get tool packages created and pushed.

@baronfel
Copy link
Member

baronfel commented Jan 4, 2023

@JiaqiWang18 is there source for jackywant118.botsay available?

@marcpopMSFT marcpopMSFT requested a review from baronfel January 18, 2023 22:20
@knocte
Copy link

knocte commented Jan 23, 2023

@JiaqiWang18 ping?

@JiaqiWang18
Copy link
Contributor Author

@JiaqiWang18 is there source for jackywant118.botsay available?

@baronfel Yes, I do have the source code.

@knocte
Copy link

knocte commented Feb 14, 2023

ping? :)

@marcpopMSFT marcpopMSFT requested a review from JL03-Yue July 5, 2023 22:47
@JL03-Yue
Copy link
Member

Investigating

@JL03-Yue JL03-Yue merged commit c5fabb4 into dotnet:main Aug 1, 2023
@knocte
Copy link

knocte commented Aug 1, 2023

Why was author information not preserved?

@marcpopMSFT
Copy link
Member

Why was author information not preserved?

Not sure what you mean. GH still considers jiaqiwang18 the author of this PR. It lists Annie as the merger as someone from the team has to merge.

BTW, we chatted offline and investigated ways to test this using our internal AzDO feeds but were not able to do so and decided it wasn't worth investigating further for a regression test.

@knocte
Copy link

knocte commented Aug 2, 2023

GH still considers jiaqiwang18 the author of this PR.

Right, but that's just GH, I'm referring to git.

It lists Annie as the merger as someone from the team has to merge.

Normally when a PR is merged, there are 2 commits: the one from the merger and the real commit of the PR. In this case it has been squashed to one, but when you select this option in GH, it normally preserves author information (the one you extract with git tools, such as git log), why didn't it preserve it this way? I guess you used another tool to merge. I don't think this is an acceptable policy.

@marcpopMSFT
Copy link
Member

Interesting. That seems like a bug in GH or maybe just unintended behavior of which option @JL03-Yue chose in the dropdown menu (GH includes three options when merging).

@elinor-fung
Copy link
Member

I expect this was merged with 'Create a merge commit'. All the original commits - with correct author information - are there in the actual history:
https://github.com/dotnet/sdk/commits/main/src/Cli/dotnet/commands/dotnet-tool/install/ParseResultExtension.cs

As an aside - does the sdk repo have a general policy on which option to use? In runtime, we actually only allow squash and merge as we find that makes for simpler / easier to understand history.

@marcpopMSFT
Copy link
Member

SDK has to use the merge commit option for the inter-branch codeflow as otherwise it gets confused about commits that were modified/reverted so I've left the default as that. You're right though that squash and merge is better for history most of the time.

@pokdeep
Copy link

pokdeep commented Sep 18, 2023

I think this change caused an issue I saw whilst building net8 rc1 base images in my companies build infrastructure.
We use private nuget feeds and all traffic to nuget.org is blocked, our base images tries to install the latest version of certain dotnet tools e.g. coverlet.console, so we don't specify as version, but with this change it tries to connect to nuget.org to get latest versions causing the build to fail.

A workaround is to specify the version flag, e.g. dotnet tool install coverlet.console --version 6.0.0 or dotnet tool install coverlet.console --version 6 as a partial pin
stacktrace.txt

@marcpopMSFT
Copy link
Member

@pokdeep please file a separate issue with the details and we'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants