1

I am trying to interrogate the version of the .NET Core that my web app was compiled with. The app is deployed on a Raspberry Pi 2 with Linux 4.9.28-v7+ armv7l. Not seeing an obvious way to do it.

Is this even possible?

AngryHacker
  • 59,598
  • 102
  • 325
  • 594
  • Not sure if this helps, but might be related: https://stackoverflow.com/questions/325918/how-to-find-out-which-version-of-the-net-framework-an-executable-needs-to-run – DMarczak Nov 13 '18 at 04:54

1 Answers1

1

You can use the following snippet:

var framework = Assembly
    .GetEntryAssembly()?
    .GetCustomAttribute<TargetFrameworkAttribute>()?
    .FrameworkName;

var stats = new
{                
    OsPlatform = System.Runtime.InteropServices.RuntimeInformation.OSDescription,
    AspDotnetVersion = framework
};

Code found on: weblog.west-wind.com

When run on my pc it returns:

Microsoft Windows 10.0.17134 
.NETCoreApp,Version=v2.1
SynerCoder
  • 12,493
  • 4
  • 47
  • 78
  • The app is already deployed. I need to interrogate the deployed app - source can't be changed. – AngryHacker Nov 14 '18 at 18:44
  • If you have access to the dll files you can load on of those assemblies. Instead of calling `Assembly.GetEntryAssembly()` you call 'Assembly.LoadFile("Path/too/app.dll")' – SynerCoder Nov 15 '18 at 08:45
  • If you wish to get the .version using http... no way unless you created the app to provide that version inside a http header or something. And that can be done using the code in my answer to get the version, and the on every request set a header with that data. – SynerCoder Nov 15 '18 at 08:47