The following code incorrectly reports that I am using CoreCLR on Windows PowerShell 5.1
|
# Use the .NET Core APIs to determine the current platform. |
|
# If a runtime exception is thrown, we are on Windows PowerShell, not PowerShell Core, |
|
# because System.Runtime.InteropServices.RuntimeInformation |
|
# and System.Runtime.InteropServices.OSPlatform do not exist in Windows PowerShell. |
|
try { |
|
$Runtime = [System.Runtime.InteropServices.RuntimeInformation] |
|
$OSPlatform = [System.Runtime.InteropServices.OSPlatform] |
|
|
|
$environment += @{'IsCoreCLR' = $true} |
|
$environment += @{'IsLinux' = $Runtime::IsOSPlatform($OSPlatform::Linux)} |
|
$environment += @{'IsMacOS' = $Runtime::IsOSPlatform($OSPlatform::OSX)} |
|
$environment += @{'IsWindows' = $Runtime::IsOSPlatform($OSPlatform::Windows)} |
|
} catch { |
|
$environment += @{'IsCoreCLR' = $false} |
|
$environment += @{'IsLinux' = $false} |
|
$environment += @{'IsMacOS' = $false} |
|
$environment += @{'IsWindows' = $true} |
|
} |
Steps to reproduce
Import-Module .\build.psm1
Get-EnvironmentInformation
Expected behavior
IsAdmin : False
IsLinux : False
IsCoreCLR : False
IsWindows : True
IsMacOS : False
nugetPackagesRoot : C:\Users\MarkLocal\.nuget\packages
Actual behavior
IsAdmin : False
IsLinux : False
IsCoreCLR : True
IsWindows : True
IsMacOS : False
nugetPackagesRoot : C:\Users\MarkLocal\.nuget\packages
Environment data
Name Value
---- -----
PSVersion 5.1.15063.726
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.726
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
The following code incorrectly reports that I am using CoreCLR on Windows PowerShell 5.1
PowerShell/build.psm1
Lines 100 to 117 in 7dce411
Steps to reproduce
Expected behavior
Actual behavior
Environment data