Skip to content

Commit

Permalink
R11PIT-775 - Update hosting bundle from .NET Core 3.1 to .NET 6.0 (#112)
Browse files Browse the repository at this point in the history
* R11PIT-775 - Update hosting bundle from .NET Core 3.1 to .NET 6.0

* Update comments

* Update wrong version

* Fix comment

* Bumped version and updated CHANGELOG

Co-authored-by: Luísa Lourenço <[email protected]>
  • Loading branch information
OS-tiagobarroso and luisalourenco authored Aug 5, 2022
1 parent edc92c2 commit 16501b1
Show file tree
Hide file tree
Showing 8 changed files with 447 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Outsystems.SetupTools Release History

## 3.16.0.0

- Upgrade the hosting bundle to .NET 6.0

## 3.15.0.0

- Fix lifetime installer checks
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 3.15.0.{build}
version: 3.16.0.{build}

only_commits:
files:
Expand Down
63 changes: 57 additions & 6 deletions src/Outsystems.SetupTools/Functions/Get-OSServerPreReqs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -163,28 +163,39 @@ function Get-OSServerPreReqs
}
default
{
# Check .NET Core Windows Server Hosting version
# Check .NET Core / .NET Windows Server Hosting version
$fullVersion = [version]"$MajorVersion.$MinorVersion.$PatchVersion.0"
if ($fullVersion -eq [version]"$MajorVersion.0.0.0")
{
# Here means that no specific minor and patch version were specified
# So we install both versions
# So we install all versions
$requireDotNetCoreHostingBundle2 = $true
$requireDotNetCoreHostingBundle3 = $true
$requireDotNetHostingBundle6 = $true
}
elseif ($fullVersion -ge [version]"11.17.1.0")
{
# Here means that minor and patch version were specified and we are equal or above version 11.17.1.0
# We install .NET 6.0 only
$requireDotNetCoreHostingBundle2 = $false
$requireDotNetCoreHostingBundle3 = $false
$requireDotNetHostingBundle6 = $true
}
elseif ($fullVersion -ge [version]"11.12.2.0")
{
# Here means that minor and patch version were specified and we are equal or above version 11.12.2.0
# We install version 3 only
# We install .NET Core 3.1 only
$requireDotNetCoreHostingBundle2 = $false
$requireDotNetCoreHostingBundle3 = $true
$requireDotNetHostingBundle6 = $false
}
else
{
# Here means that minor and patch version were specified and we are below version 11.12.2.0
# We install version 2 only
# We install .NET Core 2.1 only
$requireDotNetCoreHostingBundle2 = $true
$requireDotNetCoreHostingBundle3 = $false
$requireDotNetHostingBundle6 = $false
}

if($requireDotNetCoreHostingBundle2) {
Expand All @@ -194,7 +205,7 @@ function Get-OSServerPreReqs
$Status = $False
foreach ($version in GetDotNetCoreHostingBundleVersions)
{
# Check version 2.1
# Check .NET Core 2.1
if (([version]$version).Major -eq 2 -and ([version]$version) -ge [version]$script:OSDotNetCoreHostingBundleReq['2']['Version']) {
$Status = $True
}
Expand Down Expand Up @@ -234,7 +245,7 @@ function Get-OSServerPreReqs
$Status = $False
foreach ($version in GetDotNetCoreHostingBundleVersions)
{
# Check version 3.1
# Check .NET Core 3.1
if (([version]$version).Major -eq 3 -and ([version]$version) -ge [version]$script:OSDotNetCoreHostingBundleReq['3']['Version']) {
$Status = $True
}
Expand Down Expand Up @@ -263,6 +274,46 @@ function Get-OSServerPreReqs
}


return $(CreateResult -Status $Status -IISStatus $IISStatus -OKMessages $OKMessages -NOKMessages $NOKMessages)
}
}

if ($requireDotNetHostingBundle6) {
$RequirementStatuses += CreateRequirementStatus -Title ".NET 6.0 Windows Server Hosting" `
-ScriptBlock `
{
$Status = $False
foreach ($version in GetDotNetHostingBundleVersions)
{
# Check version 6.0
if (([version]$version).Major -eq 6 -and ([version]$version) -ge [version]$script:OSDotNetHostingBundleReq['6']['Version']) {
$Status = $True
}
}
$OKMessages = @("Minimum .NET 6.0.6 Windows Server Hosting found.")
$NOKMessages = @("Minimum .NET 6.0.6 Windows Server Hosting not found.")
$IISStatus = $True

if (Get-Command Get-WebGlobalModule -errorAction SilentlyContinue)
{
$aspModules = Get-WebGlobalModule | Where-Object { $_.Name -eq "aspnetcoremodulev2" }
if ($Status)
{
# Check if IIS can find ASP.NET modules
if ($aspModules.Count -lt 1)
{
$Status = $False
$IISStatus = $False
$NOKMessages = @("IIS can't find ASP.NET modules")
}
else
{
$IISStatus = $True
}
}
}


return $(CreateResult -Status $Status -IISStatus $IISStatus -OKMessages $OKMessages -NOKMessages $NOKMessages)
}
}
Expand Down
89 changes: 85 additions & 4 deletions src/Outsystems.SetupTools/Functions/Install-OSServerPreReqs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -146,47 +146,70 @@ function Install-OSServerPreReqs
}
default
{
# Check .NET Core Windows Server Hosting version
# Check .NET Core / .NET Windows Server Hosting version
$fullVersion = [version]"$MajorVersion.$MinorVersion.$PatchVersion.0"
if ($fullVersion -eq [version]"$MajorVersion.0.0.0")
{
# Here means that no specific minor and patch version were specified
# So we install both versions
# So we install all versions
$installDotNetCoreHostingBundle2 = $true
$installDotNetCoreHostingBundle3 = $true
$installDotNetHostingBundle6 = $true
}
elseif ($fullVersion -ge [version]"11.17.1.0")
{
# Here means that minor and patch version were specified and we are equal or above version 11.17.1.0
# We install .NET 6.0 only
$installDotNetCoreHostingBundle2 = $false
$installDotNetCoreHostingBundle3 = $false
$installDotNetHostingBundle6 = $true
}
elseif ($fullVersion -ge [version]"11.12.2.0")
{
# Here means that minor and patch version were specified and we are equal or above version 11.12.2.0
# We install version 3 only
$installDotNetCoreHostingBundle2 = $false
$installDotNetCoreHostingBundle3 = $true
$installDotNetHostingBundle6 = $false
}
else
{
# Here means that minor and patch version were specified and we are below version 11.12.2.0
# We install version 2 only
$installDotNetCoreHostingBundle2 = $true
$installDotNetCoreHostingBundle3 = $false
$installDotNetHostingBundle6 = $false
}

foreach ($version in GetDotNetCoreHostingBundleVersions)
{
# Check version 2.1
# Check .NET Core 2.1
if (([version]$version).Major -eq 2 -and ([version]$version) -ge [version]$script:OSDotNetCoreHostingBundleReq['2']['Version']) {
$installDotNetCoreHostingBundle2 = $false
}
# Check version 3.1
# Check .NET Core 3.1
if (([version]$version).Major -eq 3 -and ([version]$version) -ge [version]$script:OSDotNetCoreHostingBundleReq['3']['Version']) {
$installDotNetCoreHostingBundle3 = $false
}
}

foreach ($version in GetDotNetHostingBundleVersions)
{
# Check .NET 6.0
if (([version]$version).Major -eq 6 -and ([version]$version) -ge [version]$script:OSDotNetHostingBundleReq['6']['Version']) {
$installDotNetHostingBundle6 = $false
}
}

if ($installDotNetCoreHostingBundle2) {
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Minimum .NET Core Windows Server Hosting version 2.1 for OutSystems $MajorVersion not found. We will try to download and install the latest .NET Core Windows Server Hosting bundle"
}
if ($installDotNetCoreHostingBundle3) {
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Minimum .NET Core Windows Server Hosting version 3.1 for OutSystems $MajorVersion not found. We will try to download and install the latest .NET Core Windows Server Hosting bundle"
}
if ($installDotNetHostingBundle6) {
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Minimum .NET Windows Server Hosting version 6.0.6 for OutSystems $MajorVersion not found. We will try to download and install the latest .NET Windows Server Hosting bundle"
}
}
}

Expand Down Expand Up @@ -423,6 +446,64 @@ function Install-OSServerPreReqs
}
}

# Install .NET Windows Server Hosting bundle version 6
if ($installDotNetHostingBundle6)
{
try
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Installing .NET 6.0 Windows Server Hosting bundle"
$exitCode = InstallDotNetHostingBundle -MajorVersion '6' -Sources $SourcePath
}
catch [System.IO.FileNotFoundException]
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Exception $_.Exception -Stream 3 -Message ".NET 6.0 installer not found"
WriteNonTerminalError -Message ".NET 6.0 installer not found"

$installResult.Success = $false
$installResult.ExitCode = -1
$installResult.Message = '.NET 6.0 installer not found'

return $installResult
}
catch
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Exception $_.Exception -Stream 3 -Message "Error downloading or starting the .NET 6.0 installation"
WriteNonTerminalError -Message "Error downloading or starting the .NET 6.0 installation"

$installResult.Success = $false
$installResult.ExitCode = -1
$installResult.Message = 'Error downloading or starting the .NET 6.0 installation'

return $installResult
}

switch ($exitCode)
{
0
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message ".NET 6.0 Windows Server Hosting bundle successfully installed."
}

{ $_ -in 3010, 3011 }
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message ".NET 6.0 Windows Server Hosting bundle successfully installed but a reboot is needed. Exit code: $exitCode"
$installResult.RebootNeeded = $true
}

default
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 3 -Message "Error installing .NET 6.0 Windows Server Hosting bundle. Exit code: $exitCode"
WriteNonTerminalError -Message "Error installing .NET 6.0 Windows Server Hosting bundle. Exit code: $exitCode"

$installResult.Success = $false
$installResult.ExitCode = $exitCode
$installResult.Message = 'Error installing .NET 6.0 Windows Server Hosting bundle'

return $installResult
}
}
}

# Install .NET
if ($installDotNet)
{
Expand Down
10 changes: 10 additions & 0 deletions src/Outsystems.SetupTools/Lib/Constants.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ $OSDotNetCoreHostingBundleReq = @{
}
}

# .NET Hosting Bundle related
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
$OSDotNetHostingBundleReq = @{
'6' = @{
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'
}
}

# Database default timeout
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
$OSDBTimeout = "60"
Expand Down
60 changes: 60 additions & 0 deletions src/Outsystems.SetupTools/Lib/PlatformSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,32 @@ function GetDotNetCoreHostingBundleVersions()
return $version
}

function GetDotNetHostingBundleVersions()
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Getting the contents of the registry key HKLM:SOFTWARE\WOW6432Node\Microsoft\Updates\.NET\Microsoft .Net<*>Windows Server Hosting<*>\PackageVersion"

$rootPath = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Updates\.NET'
$filter = 'Microsoft .Net*Windows Server Hosting*'

try
{
$version = $(Get-ChildItem -Path $rootPath -ErrorAction Stop | Where-Object { $_.PSChildName -like $filter } | Get-ItemProperty -ErrorAction Stop).PackageVersion | Sort-Object -Descending
}
catch
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message $($_.Exception.Message)
}

if (-not $version)
{
$version = '0.0.0.0'
}

LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Returning $version"

return $version
}

function InstallDotNet([string]$Sources, [string]$URL)
{
if ($Sources)
Expand Down Expand Up @@ -431,6 +457,40 @@ function InstallDotNetCoreHostingBundle([string]$MajorVersion, [string]$Sources)
return $($result.ExitCode)
}

function InstallDotNetHostingBundle([string]$MajorVersion, [string]$Sources)
{
if ($Sources)
{
if (Test-Path "$Sources\$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName'])")
{
$installer = "$Sources\$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName'])"
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local file: $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:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName']).exe")
{
$installer = "$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName']).exe"
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local fallback file: $installer"
}
else {
throw [System.IO.FileNotFoundException] "$installerName.exe not found."
}
}
else
{
$installer = "$ENV:TEMP\$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName'])"
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Downloading sources from: $($script:OSDotNetHostingBundleReq[$MajorVersion]['ToInstallDownloadURL'])"
DownloadOSSources -URL $($script:OSDotNetHostingBundleReq[$MajorVersion]['ToInstallDownloadURL']) -SavePath $installer
}

LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Starting the installation"
$result = Start-Process -FilePath $installer -ArgumentList "/install", "/quiet", "/norestart" -Wait -PassThru -ErrorAction Stop

LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Installation finished. Returnig $($result.ExitCode)"

return $($result.ExitCode)
}

function InstallErlang([string]$InstallDir, [string]$Sources)
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Starting the installation"
Expand Down
2 changes: 1 addition & 1 deletion src/Outsystems.SetupTools/OutSystems.SetupTools.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'OutSystems.SetupTools.psm1'

# Version number of this module.
ModuleVersion = '3.15.0.0'
ModuleVersion = '3.16.0.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
Loading

0 comments on commit 16501b1

Please sign in to comment.