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

Only upgrade .NET tools when an update is available instead of reinstalling everytime #575

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thecatcore
Copy link
Contributor

Standards checklist:

  • The PR title is descriptive.
  • I have read CONTRIBUTING.md
  • The code compiles (cargo build)
  • The code passes rustfmt (cargo fmt)
  • The code passes clippy (cargo clippy)
  • The code passes tests (cargo test)
  • Optional: I have tested the code myself

For new steps

  • Optional: Topgrade skips this step where needed
  • Optional: The --dry-run option works with this step
  • Optional: The --yes option works with this step if it is supported by
    the underlying command

If you developed a feature or a bug fix for someone else and you do not have the
means to test it, please tag this person here.

@SteveLauC
Copy link
Member

So even if an update is not available, dotnet tool update <package> will still update (reinstall) it?

@SteveLauC
Copy link
Member

I just tried it on my host, and it seems that dotnet update will reinstall a package even though it is already the latest version:

$ dotnet tool list --global
Package Id       Version         Commands
--------------------------------------------
dotnet-dump      7.0.447801      dotnet-dump

$ stat ~/.dotnet/tools/dotnet-dump
  File: /home/steve/.dotnet/tools/dotnet-dump
  Size: 97448           Blocks: 192        IO Block: 4096   regular file
Device: 0,41    Inode: 2044812     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/   steve)   Gid: ( 1000/   steve)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2023-10-14 19:41:35.939916631 +0800
Modify: 2023-10-14 19:41:35.938916648 +0800
Change: 2023-10-14 19:41:35.946916515 +0800
 Birth: 2023-10-14 19:41:35.938916648 +0800

$ dotnet tool update dotnet-dump --global
Tool 'dotnet-dump' was reinstalled with the latest stable version (version '7.0.447801').

$ stat ~/.dotnet/tools/dotnet-dump
  File: /home/steve/.dotnet/tools/dotnet-dump
  Size: 97448           Blocks: 192        IO Block: 4096   regular file
Device: 0,41    Inode: 2044937     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/   steve)   Gid: ( 1000/   steve)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2023-10-14 19:42:36.953904808 +0800
Modify: 2023-10-14 19:42:36.953904808 +0800
Change: 2023-10-14 19:42:36.960904692 +0800
 Birth: 2023-10-14 19:42:36.952904825 +0800

// One thing to note is that .NET SDK respect locale, which means this
// header can be printed in languages other than English, do NOT use it
// to do any check.
.skip(2)
Copy link
Member

Choose a reason for hiding this comment

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

It seems that dotnet search <PKG> won't output this header if <PKG> is not found:

$ dotnet tool search rust
Could not find any results.

Will this happen if the package has already been installed?

Copy link
Member

Choose a reason for hiding this comment

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

If an installed package listed by dotnet tool list --global is guaranteed to be found with dotnet tool search <PKG>, then we can use the --take 1 option to find the exact match:

$ dotnet tool search dotnet-dump
Package ID                     Latest Version      Authors               Downloads      Verified
------------------------------------------------------------------------------------------------
dotnet-dump                    7.0.447801          Microsoft             21089065
dotnet-gcdump                  7.0.447801          Microsoft             9036932
dumpdiag                       0.10.0              DumpDiag              2427
netspark.tools.dumpconfig      1.0.0               Gennadii Kostrov      286

$ dotnet tool search dotnet-dump --take 1
Package ID       Latest Version      Authors        Downloads      Verified
---------------------------------------------------------------------------
dotnet-dump      7.0.447801          Microsoft      21089065

Copy link
Contributor Author

@thecatcore thecatcore Nov 16, 2023

Choose a reason for hiding this comment

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

It seems like dotnet tool doesn't take into account whether the tool version supports the installed toolchain or not.
For example for package dotnet-ef, a few days ago version 8.0.0 released, dropping support for pre-dotnet-8.0, but the cli still tried installing the update, and it's still showing as latest available using dotnet tool search. Even tho I only had 6.0 and 7.0 installed.

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

Successfully merging this pull request may close these issues.

None yet

2 participants