OctopusDeploy / Library

| Public | A repository of step templates and other community-contributed extensions to Octopus Deploy
Other
171 stars 503 forks source link

asp.net check fails with new versions using new registry key #1491

Closed hairymonkeynuts closed 8 months ago

hairymonkeynuts commented 8 months ago

Step template

step-templates/windows-check-net-core-framework-version.json

Step version

No response

Octopus version

2023.4.8307

Step template parameter inputs

No response

What happened

When enabling ASP.Net version checking the registry key checks .NET Core however newer versions have dropped the Core from the key and only populate the .Net key now.

Reproduction steps

install 6.0.28 hosting bundle on a agent, set step for version 6.0, NOT exact, check for asp.net version. It will find the .net runtime but fail on the asp.net because the registry key has changed.

More Information

The original is in the commented section. The "active" section is the new registry key the package is using.


<#

function Get-AspDotNetCoreRuntimeVersions() {
    $aspDotNetCoreRuntimeVersions = @()
    $DotNETCoreUpdatesPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates\.NET Core" 
    $DotNetCoreItems = Get-Item -Path $DotNETCoreUpdatesPath 
    $aspDotNetCoreRuntimeVersions = $DotNetCoreItems.GetSubKeyNames() | where { $_ -match "^Microsoft (ASP)?\.NET Core (?<version>[\d\.]+(.*?)?) "} | foreach { $Matches['version'] }

    return $aspDotNetCoreRuntimeVersions
}
#>

# starting with 6 the "core" was dropped from the key
function Get-AspDotNetCoreRuntimeVersions() {
    $aspDotNetCoreRuntimeVersions = @()
    $DotNETCoreUpdatesPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates\.NET" 
    $DotNetCoreItems = Get-Item -Path $DotNETCoreUpdatesPath 
    $aspDotNetCoreRuntimeVersions = $DotNetCoreItems.GetSubKeyNames() | where { $_ -match "^Microsoft (ASP)?\.NET (?<version>[\d\.]+(.*?)?) "} | foreach { $Matches['version'] }

    return $aspDotNetCoreRuntimeVersions
}
harrisonmeister commented 8 months ago

This should be resolved now as a result of #1495