Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PowerShell Coreの.NET Coreランタイムバージョンまとめ
function Get-NETCoreRuntimeVersion () {
# pwsh.deps.jsonを検索
$depsJsonPath = Join-Path $PSHOME 'pwsh.deps.json'
if (Test-Path $depsJsonPath) {
$depsContent = Get-Content -LiteralPath $depsJsonPath | ConvertFrom-Json -AsHashtable
$targetName = $depsContent.runtimeTarget.name
$pwshTargetName = $depsContent.targets.$targetName.Keys | ? { $_ -like "pwsh*" }
return $depsContent.targets.$targetName.$pwshTargetName.dependencies."Microsoft.NETCore.App"
}
# pwsh.deps.jsonが無い場合は System.Runtime.dll に埋め込まれている情報を使う
# System.Runtime.dll から CoreFx のコミットIDを取得
$asm = [System.Reflection.Assembly]::GetAssembly([Lazy[object,object]])
$versionInfo = $asm.GetCustomAttributes([System.Reflection.AssemblyInformationalVersionAttribute], $true).InformationalVersion
$commitId = (($versionInfo -split ' ')[-1] -split '/')[-1]
if ("" -eq $commitId) {
Write-Error ('Failed to get git commitid.(versionInfo = {0})' -f $versionInfo)
return ""
}
# コミットIDと対になるバージョンを検索
$gitVersionTag = (Invoke-RestMethod -Uri 'https://api.github.com/repos/dotnet/corefx/tags') |
Where-Object { $_.commit.url -like "*$commitId" } |
Select-Object -ExpandProperty Name
if ($null -eq $gitVersionTag) {
Write-Warning ('Failed to get git version.(commitid = {0})' -f $commitId)
return ""
}
# e.g. v2.1.8 -> 2.1.8
return $gitVersionTag.Substring(1)
}

PowerShell Coreの.NET Coreランタイムバージョンまとめ

PowerShell Core ランタイムバージョン
6.0.0 2.0.4
6.0.1 2.0.5
6.0.2 2.0.6
6.0.3 2.0.7
6.0.4 2.0.7
6.0.5 2.0.7
6.1.0 2.1.3
6.1.1 2.1.5
6.1.2 2.1.7
6.1.3 2.1.8
6.2.0 2.1.8

余談

まあ、ぶっちゃけPowerShell Coreに限った話ならランタイムバージョンはGitHubのソース追った方が早い。

$versionTags = (
    'v6.0.0', 'v6.0.1', 'v6.0.2', 'v6.0.3', 'v6.0.4', 'v6.0.5',
    'v6.1.0', 'v6.1.1', 'v6.1.2', 'v6.1.3',
    'v6.2.0'
)
foreach ($tag in $versionTags) {
    $content = Invoke-RestMethod "https://raw.githubusercontent.com/PowerShell/PowerShell/$tag/PowerShell.Common.props"
    $runtimeVersion = [string]$content.Project.PropertyGroup.RuntimeFrameworkVersion
    Write-Output ('{0} : {1}' -f $tag, $runtimeVersion)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.