3

The following code is valid for the dnx451 framework but not the dnxcore50

string ver = Environment.Version

This method does not exist:

enter image description here

Is there an equivalent property in the dnxcore50 framework?

Update

as per Victors answer you can use PlatformServices.Default.Runtime eg:

Console.WriteLine("env: {0} {1}", PlatformServices.Default.Runtime.RuntimeType, PlatformServices.Default.Runtime.RuntimeVersion);

output: (on dnx451)

env: Clr 1.0.0-rc1-16231

output: (on dnxcore50)

env: CoreClr 1.0.0-rc1-16231

wal
  • 17,409
  • 8
  • 74
  • 109
  • It corresponds [the documentation](http://dotnet.github.io/api/System.Environment.html#properties). It seems that `Version` property is dropped. – Oleg Feb 02 '16 at 08:58

1 Answers1

2

You can use the properties in IRuntimeEnvironment to get information about the runtime. The following properties are available:

  • RuntimeType
  • RuntimeArchitecture
  • RuntimeVersion
  • RuntimePath
Victor Hurdugaci
  • 28,177
  • 5
  • 87
  • 103
  • ...and use `new DefaultRuntimeEnvironment().RuntimeVersion` ?? – wal Feb 02 '16 at 23:39
  • `Microsoft.Extensions.PlatformAbstractions.dll` doesnt contain `DefaultRuntimeEnvironment` (in rc1) - can you please elaborate on how this works ? – wal Feb 03 '16 at 07:01
  • 1
    Use `PlatformServices.Default.Runtime`. Here's an example: https://github.com/aspnet/Testing/blob/1.0.0-rc1/src/Microsoft.AspNet.Testing/TestPlatformHelper.cs#L11 – Victor Hurdugaci Feb 04 '16 at 01:18
  • 1
    Here is what I used with dotnet core 1.1: `Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.RuntimeFramework.Version` after including nuget package Microsoft.Extensions.PlatformAbstractions – LosManos Apr 05 '17 at 19:31