Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Outsystems.SetupTools/Functions/Install-OSServerPreReqs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ function Install-OSServerPreReqs
$installDotNetHostingBundle8 = $true
$installDotNetHostingBundle10 = $false
$mostRecentHostingBundleVersion = [version]$script:OSDotNetHostingBundleReq['8']['Version']
$dotNetCoreUninstallToolVersion = $script:OSDotNetHostingBundleReq['8']['UninstallerVersion']
$dotNetCoreUninstallToolDisplayVersion = $script:OSDotNetCoreUninstallReq[$dotNetCoreUninstallToolVersion]['DisplayVersion']
}
elseif ($fullVersion -ge [version]"11.40.2.0")
{
Expand All @@ -212,6 +214,8 @@ function Install-OSServerPreReqs
$installDotNetHostingBundle8 = $true
$installDotNetHostingBundle10 = $false
$mostRecentHostingBundleVersion = [version]$script:OSDotNetHostingBundleReq['8']['Version']
$dotNetCoreUninstallToolVersion = $script:OSDotNetHostingBundleReq['8']['UninstallerVersion']
$dotNetCoreUninstallToolDisplayVersion = $script:OSDotNetCoreUninstallReq[$dotNetCoreUninstallToolVersion]['DisplayVersion']
}
elseif ($fullVersion -ge [version]"11.27.0.0")
{
Expand All @@ -221,6 +225,8 @@ function Install-OSServerPreReqs
$installDotNetHostingBundle8 = $true
$installDotNetHostingBundle10 = $false
$mostRecentHostingBundleVersion = [version]$script:OSDotNetHostingBundleReq['8']['Version']
$dotNetCoreUninstallToolVersion = $script:OSDotNetHostingBundleReq['8']['UninstallerVersion']
$dotNetCoreUninstallToolDisplayVersion = $script:OSDotNetCoreUninstallReq[$dotNetCoreUninstallToolVersion]['DisplayVersion']
}
else
{
Expand All @@ -229,6 +235,8 @@ function Install-OSServerPreReqs
$installDotNetHostingBundle8 = $false
$installDotNetHostingBundle10 = $false
$mostRecentHostingBundleVersion = [version]$script:OSDotNetHostingBundleReq['6']['Version']
$dotNetCoreUninstallToolVersion = $script:OSDotNetHostingBundleReq['6']['UninstallerVersion']
$dotNetCoreUninstallToolDisplayVersion = $script:OSDotNetCoreUninstallReq[$dotNetCoreUninstallToolVersion]['DisplayVersion']
}

foreach ($version in GetDotNetHostingBundleVersions)
Expand Down Expand Up @@ -553,13 +561,13 @@ function Install-OSServerPreReqs

if ($mostRecentHostingBundleVersion -and $RemovePreviousHostingBundlePackages)
{
$isInstalled = IsDotNetCoreUninstallToolInstalled
$isInstalled = IsDotNetCoreUninstallToolInstalled -DisplayVersion $dotNetCoreUninstallToolDisplayVersion
if (-not $isInstalled)
{
try
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Installing .NET Uninstall Tool"
$exitCode = InstallDotNetCoreUninstallTool -MajorVersion '1.5' -Sources $SourcePath
$exitCode = InstallDotNetCoreUninstallTool -MajorVersion $dotNetCoreUninstallToolVersion -Sources $SourcePath
}
catch [System.IO.FileNotFoundException]
{
Expand Down
13 changes: 12 additions & 1 deletion src/Outsystems.SetupTools/Lib/Constants.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,25 @@ $OSDotNetHostingBundleReq = @{
Version = '6.0.6'
ToInstallDownloadURL = 'https://download.visualstudio.microsoft.com/download/pr/0d000d1b-89a4-4593-9708-eb5177777c64/cfb3d74447ac78defb1b66fd9b3f38e0/dotnet-hosting-6.0.6-win.exe'
InstallerName = 'DotNet_WindowsHosting_6.exe'
UninstallerVersion = '1.5'
}
'8' = @{
Version = '8.0.0'
ToInstallDownloadURL = 'https://download.visualstudio.microsoft.com/download/pr/2a7ae819-fbc4-4611-a1ba-f3b072d4ea25/32f3b931550f7b315d9827d564202eeb/dotnet-hosting-8.0.0-win.exe'
InstallerName = 'DotNet_WindowsHosting_8.exe'
UninstallerVersion = '1.7'
}
'10' = @{
Version = '10.0.2'
ToInstallDownloadURL = 'https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/10.0.2/dotnet-hosting-10.0.2-win.exe'
InstallerName = 'DotNet_WindowsHosting_10.exe'
UninstallerVersion = '1.7'
}
'11' = @{
Version = '11.0.0'
ToInstallDownloadURL = 'https://download.visualstudio.microsoft.com/download/pr/2a7ae819-fbc4-4611-a1ba-f3b072d4ea25/32f3b931550f7b315d9827d564202eeb/dotnet-hosting-8.0.0-win.exe'
InstallerName = 'DotNet_WindowsHosting_8.exe'
UninstallerVersion = '1.7'
}
}

Expand All @@ -129,7 +133,14 @@ $OSDotNetCoreUninstallReq = @{
'1.5' = @{
Version = '1.5.255402'
ToInstallDownloadURL = 'https://github.com/dotnet/cli-lab/releases/download/1.5.255402/dotnet-core-uninstall-1.5.255402.msi'
InstallerName = 'DotNetCore_Uninstall_15.msi'
InstallerName = 'DotNetCore_Uninstall.msi'
DisplayVersion = '4.80.595'
}
'1.7' = @{
Version = '1.7.661902'
ToInstallDownloadURL = 'https://github.com/dotnet/cli-lab/releases/download/1.7.661902/dotnet-core-uninstall.msi'
InstallerName = 'DotNetCore_Uninstall.msi'
DisplayVersion = '4.112.868'
}
}

Expand Down
31 changes: 23 additions & 8 deletions src/Outsystems.SetupTools/Lib/PlatformSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@ function InstallDotNetHostingBundle([string]$MajorVersion, [string]$Sources, [bo
# If Windows is set to hide file extensions from file names, the file could have been stored with double extension by mistake.
elseif (Test-Path "$Sources\$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName']).exe")
{
$installer = "$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName']).exe"
$installer = "$Sources\$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName']).exe"
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local fallback file: $installer"
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
}
else {
throw [System.IO.FileNotFoundException] "$installerName.exe not found."
throw [System.IO.FileNotFoundException] "$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName']) not found in $Sources."
}
}
else
Expand Down Expand Up @@ -428,14 +428,14 @@ function InstallDotNetCoreUninstallTool([string]$MajorVersion, [string]$Sources)
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
}
# If Windows is set to hide file extensions from file names, the file could have been stored with double extension by mistake.
elseif (Test-Path "$Sources\$($script:OSDotNetCoreUninstallReq[$MajorVersion]['InstallerName']).exe")
elseif (Test-Path "$Sources\$($script:OSDotNetCoreUninstallReq[$MajorVersion]['InstallerName']).msi")
{
$installer = "$($script:OSDotNetCoreUninstallReq[$MajorVersion]['InstallerName']).exe"
$installer = "$Sources\$($script:OSDotNetCoreUninstallReq[$MajorVersion]['InstallerName']).msi"
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local fallback file: $installer"
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
}
else {
throw [System.IO.FileNotFoundException] "$installerName.exe not found."
throw [System.IO.FileNotFoundException] "$($script:OSDotNetCoreUninstallReq[$MajorVersion]['InstallerName']) not found in $Sources."
}
}
else
Expand All @@ -452,20 +452,35 @@ function InstallDotNetCoreUninstallTool([string]$MajorVersion, [string]$Sources)
return $($result.ExitCode)
}

function IsDotNetCoreUninstallToolInstalled()
function IsDotNetCoreUninstallToolInstalled([string]$DisplayVersion)
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Checking if registry key of .NET Core Uninstall Tool exists in HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"

$rootPath = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
$filter = '*Microsoft .NET Core SDK Uninstall Tool (x86)*'

$item = Get-ChildItem -Path $rootPath -ErrorAction Stop | Get-ItemProperty -Name DisplayName -ErrorAction SilentlyContinue | Where-Object { $_ -like $filter}

# There can only be one uninstaller in the registry but just in case the query returns an array we return only one
$item = Get-ChildItem -Path $rootPath -ErrorAction Stop | Get-ItemProperty -Name DisplayName -ErrorAction SilentlyContinue | Where-Object { $_ -like $filter} | Select-Object -First 1
if (-not $item)
{
return $false
}

$itemDisplayVersion = $(Get-ItemProperty $item.PSPath -ErrorAction SilentlyContinue).DisplayVersion
$itemVersion = $null

# If the installed version cannot be determined, assume the tool needs to be installed
if (-not [version]::TryParse($itemDisplayVersion, [ref]$itemVersion))
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Could not determine the installed version of the .NET Core Uninstall Tool"
return $false
}

if ($itemVersion -lt $DisplayVersion)
{
return $false
}

return $true
}

Expand Down