I noticed that my previously very stable web apps running in Azure App Service on .NET core started throwing new errors this week.
I suspect (and it is just a guess), that the .NET Core 1.0.1 shared runtime was installed on the Azure App Service this week and that my apps rolled forward to the 1.0.1 runtime as explained here:
https://blogs.msdn.microsoft.com/dotnet/2016/09/13/announcing-september-2016-updates-for-net-core-1-0/
Going forward, I want to log what version of the Core Runtime to aid in troubleshooting.
How can I determine from within my ASPNET Core web app what version of the core runtime is running (i.e. 1.0.0 or 1.0.1)?
I've searched the entire Internet and even tried looking at the source code, but I can't find where (or if) this is exposed.
I took sometime a while ago to dig deep into the code here: https://github.com/dotnet/cli/blob/master/src/Microsoft.DotNet.Cli.Utils/Muxer.cs
I ended up using something like this: https://gist.github.com/npnelson/5bf49a145338120cacbac7ee8bd399bf
It's been working for me for awhile, but it seems like it could be pretty fragile as .NET Core evolves, so use with caution.
Update 3/28/2018 The dotnet team is actively tracking this: https://github.com/dotnet/corefx/issues/28132 Give it a thumbs up if you would like to see it become part of the API
Update 3/1/2019 This will be available as of .NET Core 3.0 Preview 4: https://github.com/dotnet/corefx/issues/35573
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With