jmalarcon / DotNetVersions

Command line tool that shows the currently installed "classic" .NET versions in your system
https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed
MIT License
436 stars 95 forks source link

Make into a `dotnet` tool? #8

Open derekantrican opened 2 years ago

derekantrican commented 2 years ago

The dotnet CLI has a handy feature of "tools" (like extensions). I could see this being a very useful one. It would make your tool very easy to install & use.

https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools-how-to-create

jmalarcon commented 2 years ago

Hi Derek:

In fact you already have this built-in in dotnet: dotnet --list-sdks

This will give you all the installed .NET SDK versions in your computer.

If you want to know all the installed .NET runtimes you can use: dotnet --list-runtimes

The whole point of creating my tool was to have something similar in the "classic" .NET framework, where knowing this information is not straightforward.

HTH

derekantrican commented 2 years ago

Yes, I am aware of dotnet --list-runtimes but this only lists the .NET Core runtimes (now just called ".NET"). That is why I suggested to you to build a tool using your code: for .NET Framework runtimes

jmalarcon commented 2 years ago

Ah!, OK. So what you're proposing, if I understood it correctly, is to create a .NET version that apart from showing the same that --list-runtimes shows, it includes the old .NET framework versions too in the result. Is that correct?

It shouldn't be difficult to pull out in Windows with the Microsoft.Win32.Registry package, I guess. It should return the same as --list-runtimes + .NET framework versions in Windows, and just the same as --list-runtimes in other operating systems...

Thanks for the suggestion.

derekantrican commented 2 years ago

Right. Per my links above, I think this would fit well as a "tool" that could be called via the dotnet CLI. Currently to see a list of installed .NET Frameworks on a computer, a user has to run something like

Powershell

Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version,Release -EA 0 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | Select PSChildName, Version, Release

https://stackoverflow.com/a/3495491/2246411

which is horrendous. Additionally, everywhere I look there seems to be caveats for 4.5+ or <=1 because of how the registry is organized differently for those versions. Someone could install your tool, but that's an additional thing to install.

However, if they happen to already have the dotnet CLI installed, I think it would be cool if they could run something like the following:

dotnet tool install list-frameworks
dotnet tool list-frameworks

Much simpler. Much cleaner.

jmalarcon commented 2 years ago

You're right. Thanks for the suggestion.

I don't know I I'll have the time soon to do something like that, but I keep the idea here for doing sometime in the future 😊

tisaconundrum2 commented 2 years ago

+1 to you also adding this to the CLI in the future! :)

Burzyn1 commented 2 years ago

+1

bgrossman commented 11 months ago

You're right. Thanks for the suggestion.

I don't know I I'll have the time soon to do something like that, but I keep the idea here for doing sometime in the future 😊

I'm happy to take a stab unless you'd prefer to do it?

jmalarcon commented 11 months ago

By all means, thank you. Just do a PR and I'll be happy to review and accept it. Thanks!