Skip to content

Instantly share code, notes, and snippets.

@solrevdev
Created July 21, 2023 11:04
Show Gist options
  • Save solrevdev/8216646bd547aff991fb693b8f1d98cc to your computer and use it in GitHub Desktop.
Save solrevdev/8216646bd547aff991fb693b8f1d98cc to your computer and use it in GitHub Desktop.
How to get the running .NET version and also the current Product version via <Version> element in csproj
using System;
using System.Reflection;
var dotnetVersion = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
Console.WriteLine($"🌄 .NET Version: {dotnetVersion}");
var productVersion = Assembly.GetEntryAssembly().GetCustomAttribute<System.Reflection.AssemblyInformationalVersionAttribute>().InformationalVersion;
Console.WriteLine($"🌄 Product Version : {productVersion}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment