Skip to content

Commit

Permalink
Merge pull request #1495 from FinnianDempsey/master
Browse files Browse the repository at this point in the history
Update windows-check-net-core-framework-version.json Registry Path for Modern NET versions
  • Loading branch information
harrisonmeister authored Mar 21, 2024
2 parents 65dc165 + 5511729 commit 5ce770a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions step-templates/windows-check-net-core-framework-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"Name": ".NET Core - Check .NET Core Framework Version",
"Description": "Check if given .NET Core framework version (or greater) is installed.",
"ActionType": "Octopus.Script",
"Version": 4,
"Version": 5,
"CommunityActionTemplateId": null,
"Properties": {
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptBody": "$ErrorActionPreference = \"Stop\" \nfunction Get-Parameter($Name, $Default, [switch]$Required) {\n $result = $null\n\n if ($OctopusParameters -ne $null) {\n $result = $OctopusParameters[$Name]\n }\n\n if ($result -eq $null) {\n if ($Required) {\n throw \"Missing parameter value $Name\"\n } else {\n $result = $Default\n }\n }\n\n return $result\n}\n\nfunction Get-DotNetCoreFrameworkVersions() {\n $dotNetCoreVersions = @()\n if(Test-Path \"$env:programfiles/dotnet/shared/Microsoft.NETCore.App\") {\n $dotNetCoreVersions = (ls \"$env:programfiles/dotnet/shared/Microsoft.NETCore.App\").Name\n }\n return $dotNetCoreVersions\n}\n\nfunction Get-AspDotNetCoreRuntimeVersions() {\n $aspDotNetCoreRuntimeVersions = @()\n\t$DotNETCoreUpdatesPath = \"Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Updates\\.NET Core\" \n\t$DotNetCoreItems = Get-Item -Path $DotNETCoreUpdatesPath \n\t$aspDotNetCoreRuntimeVersions = $DotNetCoreItems.GetSubKeyNames() | where { $_ -match \"^Microsoft (ASP)?\\.NET Core (?<version>[\\d\\.]+(.*?)?) \"} | foreach { $Matches['version'] }\n\n return $aspDotNetCoreRuntimeVersions\n}\n\n$targetVersion = (Get-Parameter \"TargetVersion\" -Required).Trim()\n$exact = [boolean]::Parse((Get-Parameter \"Exact\" -Required))\n$CheckASPdotNETCore = [boolean]::Parse((Get-Parameter \"CheckASPdotNETCore\" -Required))\n\n$matchedVersions = Get-DotNetCoreFrameworkVersions | Where-Object { if ($exact) { $_ -eq $targetVersion } else { $_ -ge $targetVersion } }\nif (!$matchedVersions) { \n throw \"Can't find .NET Core Runtime $targetVersion installed in the machine.\"\n}\n\n$matchedVersions | foreach { Write-Host \"Found .NET Core Runtime $_ installed in the machine.\" }\n\nif ($CheckASPdotNETCore) {\n $matchedAspVersions = Get-AspDotNetCoreRuntimeVersions\n if (!$matchedAspVersions) {\n throw \"Can't find ASP.NET Core Runtime installed in the machine.\"\n }\n\n $matchedAspVersions | foreach { Write-Host \"Found ASP.NET Core Runtime $_ installed in the machine.\" }\n}"
"Octopus.Action.Script.ScriptBody": "$ErrorActionPreference = \"Stop\" \nfunction Get-Parameter($Name, $Default, [switch]$Required) {\n $result = $null\n\n if ($OctopusParameters -ne $null) {\n $result = $OctopusParameters[$Name]\n }\n\n if ($result -eq $null) {\n if ($Required) {\n throw \"Missing parameter value $Name\"\n } else {\n $result = $Default\n }\n }\n\n return $result\n}\n\nfunction Get-DotNetCoreFrameworkVersions() {\n $dotNetCoreVersions = @()\n if(Test-Path \"$env:programfiles/dotnet/shared/Microsoft.NETCore.App\") {\n $dotNetCoreVersions = (ls \"$env:programfiles/dotnet/shared/Microsoft.NETCore.App\").Name\n }\n return $dotNetCoreVersions\n}\n\nfunction Get-AspDotNetCoreRuntimeVersions() {\n $aspDotNetCoreRuntimeVersions = @()\n $DotNETCoreUpdatesPath = \"Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Updates\\.NET Core\"\n $DotNETUpdatesPath = \"Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Updates\\.NET\"\n\n if (Test-Path \"HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Updates\\.NET Core\") {\n\t $DotNetCoreItems = (Get-Item -Path $DotNETCoreUpdatesPath).GetSubKeyNames()\n }\n if (Test-Path \"HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Updates\\.NET\") {\n $DotNetItems = (Get-Item -Path $DotNETUpdatesPath).GetSubKeyNames()\n }\n\t$aspDotNetCoreRuntimeVersions = $DotNetCoreItems + $DotNetItems | where { $_ -match \"^Microsoft (ASP)?\\.NET Core (?<version>[\\d\\.]+(.*?)?) \"} | foreach { $Matches['version'] }\n\n return $aspDotNetCoreRuntimeVersions\n}\n\n$targetVersion = (Get-Parameter \"TargetVersion\" -Required).Trim()\n$exact = [boolean]::Parse((Get-Parameter \"Exact\" -Required))\n$CheckASPdotNETCore = [boolean]::Parse((Get-Parameter \"CheckASPdotNETCore\" -Required))\n\n$matchedVersions = Get-DotNetCoreFrameworkVersions | Where-Object { if ($exact) { $_ -eq $targetVersion } else { $_ -ge $targetVersion } }\nif (!$matchedVersions) { \n throw \"Can't find .NET Core Runtime $targetVersion installed in the machine.\"\n}\n\n$matchedVersions | foreach { Write-Host \"Found .NET Core Runtime $_ installed in the machine.\" }\n\nif ($CheckASPdotNETCore) {\n $matchedAspVersions = Get-AspDotNetCoreRuntimeVersions\n if (!$matchedAspVersions) {\n throw \"Can't find ASP.NET Core Runtime installed in the machine.\"\n }\n\n $matchedAspVersions | foreach { Write-Host \"Found ASP.NET Core Runtime $_ installed in the machine.\" }\n}"
},
"Parameters": [
{
Expand Down Expand Up @@ -50,6 +50,6 @@
"OctopusVersion": "2018.4.1",
"Type": "ActionTemplate"
},
"LastModifiedBy": "cjuroz",
"LastModifiedBy": "FinnianDempsey",
"Category": "dotnetcore"
}

0 comments on commit 5ce770a

Please sign in to comment.