Monday, January 20, 2020

Determining installed .NET Framework versions

Getting installed .NET Framework versions is (surprisingly) not a simple task. On this post, let's try to address that.
When .NET developers have to fix problems on a remote server that requires knowing which versions of the .NET Framework are installed, they'll be frustrated. Unfortunately, the Redmond folks made it unnecessarily complicated to know the installed versions of the .NET Framework on a  Windows box.

.NET Core on the other side, does it well via the .NET Core CLI. But for those of us still on the .NET Framework, what can we do? The official documentation, describes multiple options including accessing the registry, using PowerShell and building a C# application.

The simplest and fastest solution is obviously PowerShell. So let's keep it simple, shall we?

The Solution

The solution lies on this simple PowerShell script:

Simplifying Further

Ok, but let's assume that we're on a remote server. Opening chrome and downloading this script might not be ideal. Could we somehow script this out?

Yes, by using PowerShell's Invoke-WebRequest (PowerShell's curl), we could make it a one-liner so that we don't have to even open a browser and download that script from GitHub.

Here is it:
Invoke-WebRequest -Uri https://github.com/hd9/powershell/raw/master/list-dotnet-frameworks.ps1 -OutFile list-dotnet-frameworks.ps1; .\list-dotnet-frameworks.ps1

Hope it helps!

See Also

Countdown to .NET 5.0
Creating a Ubuntu Desktop instance on Azure
Package Management in .NET Core
Building and Running ASP.NET Core apps on Linux
Why I use Fedora
Windows Subsystem for Linux, the best way to learn Linux on Windows
How I fell in love with i3

For more posts on .NET Core, please click here.
Do you have any comment on one this post? Contact me @BrunoHilden