Skip to content
Closed
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
18 changes: 18 additions & 0 deletions src/Outsystems.SetupTools/Functions/Get-OSServerPreReqs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ function Get-OSServerPreReqs
return $(CreateResult -Status $Status -OKMessages $OKMessages -NOKMessages $NOKMessages)
}

$MSVCppRedistRequirementStatus = CreateRequirementStatus -Title "Microsoft Visual C++ 2015-2022 Redistributable" `
-ScriptBlock `
{
$Status = GetMSVCppRedistInstallInfo

$OKMessages = @("Microsoft Visual C++ 2015-2022 Redistributable is installed.")
$NOKMessages = @("Microsoft Visual C++ 2015-2022 Redistributable not found, this is an OutSystems requirement.")

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

switch ($MajorVersion)
{
'10'
Expand All @@ -189,6 +200,8 @@ function Get-OSServerPreReqs
$requireDotNetCoreHostingBundle3 = $true
$requireDotNetHostingBundle6 = $true
$requireDotNetHostingBundle8 = $true
# If no minor version is specified Microsoft Visual C++ 2015-2022 Redistributable is assumed as required
$requireMSVCppRedist = $true
}
elseif ($fullVersion -ge [version]"11.27.0.0")
{
Expand Down Expand Up @@ -229,6 +242,11 @@ function Get-OSServerPreReqs
$RequirementStatuses += $MSBuildToolsRequirementStatus
}

# Check if Microsoft Visual C++ 2015-2022 Redistributable is required
if ( ($fullVersion -ge [version]"11.21.1.0") -or $requireMSVCppRedist)
{
$RequirementStatuses += $MSVCppRedistRequirementStatus
}

if($requireDotNetCoreHostingBundle2) {
$RequirementStatuses += CreateRequirementStatus -Title ".NET Core 2.1 Windows Server Hosting" `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Install-OSServerPreReqs
.EXAMPLE
Install-OSServerPreReqs -MajorVersion "11" -InstallIISMgmtConsole:$false

.EXAMPLE
.EXAMPLE
Install-OSServerPreReqs -MajorVersion "11" -InstallIISMgmtConsole:$false -SourcePath "c:\downloads"

#>
Expand Down Expand Up @@ -201,6 +201,8 @@ function Install-OSServerPreReqs
$installDotNetCoreHostingBundle3 = $true
$installDotNetHostingBundle6 = $true
$installDotNetHostingBundle8 = $true
# If no minor version is specified Microsoft Visual C++ 2015-2022 Redistributable is installed
$installMSVCppRedist = $true
}
elseif ($fullVersion -ge [version]"11.27.0.0")
{
Expand Down Expand Up @@ -279,6 +281,12 @@ function Install-OSServerPreReqs
if ($installDotNetHostingBundle8) {
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Minimum .NET Windows Server Hosting version 8.0.0 for OutSystems $MajorVersion not found. We will try to download and install the latest .NET Windows Server Hosting bundle"
}

# Check if Microsoft Visual C++ 2015-2022 Redistributable is required
if ($fullVersion -ge [version]"11.21.1.0")
{
$installMSVCppRedist = $true
}
}
}

Expand Down Expand Up @@ -737,6 +745,64 @@ function Install-OSServerPreReqs
}
}
}

# Install Microsoft Visual C++ 2015-2022 Redistributable
if ($installMSVCppRedist)
{
try
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Installing Microsoft Visual C++ 2015-2022 Redistributable"
$exitCode = InstallMSVCppRedist -Sources $SourcePath
}
catch [System.IO.FileNotFoundException]
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Exception $_.Exception -Stream 3 -Message "Microsoft Visual C++ 2015-2022 Redistributable installer not found"
WriteNonTerminalError -Message "Microsoft Visual C++ 2015-2022 Redistributable installer not found"

$installResult.Success = $false
$installResult.ExitCode = -1
$installResult.Message = 'Microsoft Visual C++ 2015-2022 Redistributable installer not found'

return $installResult
}
catch
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Exception $_.Exception -Stream 3 -Message "Error downloading or starting the Microsoft Visual C++ 2015-2022 Redistributable installation"
WriteNonTerminalError -Message "Error downloading or starting the Microsoft Visual C++ 2015-2022 Redistributable installation"

$installResult.Success = $false
$installResult.ExitCode = -1
$installResult.Message = 'Error downloading or starting the Microsoft Visual C++ 2015-2022 Redistributable installation'

return $installResult
}

switch ($exitCode)
{
0
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Microsoft Visual C++ 2015-2022 Redistributable successfully installed"
}

{ $_ -in 3010, 3011 }
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Microsoft Visual C++ 2015-2022 Redistributable 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 Microsoft Visual C++ 2015-2022 Redistributable. Exit code: $exitCode"
WriteNonTerminalError -Message "Error installing Microsoft Visual C++ 2015-2022 Redistributable. Exit code: $exitCode"

$installResult.Success = $false
$installResult.ExitCode = $exitCode
$installResult.Message = "Error installing Microsoft Visual C++ 2015-2022 Redistributable"

return $installResult
}
}
}
#endregion

#region configuration
Expand Down
10 changes: 8 additions & 2 deletions src/Outsystems.SetupTools/Lib/Constants.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ $OSSCCred = New-Object System.Management.Automation.PSCredential ($OSSCUser, $(C
$OSRepoURL = "https://ossetuptools.blob.core.windows.net/sources"
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
$OSRepoURLBuildTools = 'https://download.microsoft.com/download/E/E/D/EEDF18A8-4AED-4CE0-BEBE-70A83094FC5A/BuildTools_Full.exe'
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
$OSRepoURLMSVCppRedist = 'https://download.visualstudio.microsoft.com/download/pr/7ebf5fdb-36dc-4145-b0a0-90d3d5990a61/CC0FF0EB1DC3F5188AE6300FAEF32BF5BEEBA4BDD6E8E445A9184072096B713B/VC_redist.x64.exe'

# Microsoft Visual C++ 2015-2022 Redistributable related
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
# First version of the 2015-2022 Redistributable
$OSReqsMSVCppRedistFirstVersion = [version]'14.30.30708.0'

# .NET related
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
Expand Down Expand Up @@ -205,5 +212,4 @@ $OSPerfTuningMaxRequestLength = 262144
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
$OSPerfTuningMaxAllowedContentLength = 268435456
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
$OSPerfTuningMaxConnections = 4294967295

$OSPerfTuningMaxConnections = 4294967295
72 changes: 72 additions & 0 deletions src/Outsystems.SetupTools/Lib/PlatformSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -940,3 +940,75 @@ function GetAzStorageFileList()

return $sources
}

function InstallMSVCppRedist([string]$Sources)
{
if ($Sources)
{
if (Test-Path "$Sources\VC_Redist.x64.exe")
{
$installer = "$Sources\VC_Redist.x64.exe"
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\VC_Redist.x64.exe.exe")
{
$installer = "$Sources\VC_Redist.x64.exe.exe"
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local fallback file: $installer"
}
else {
throw [System.IO.FileNotFoundException] "VC_Redist.x64.exe not found."
}
}
else
{
$installer = "$ENV:TEMP\VC_Redist.x64.exe"
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Downloading sources from: $OSRepoURLMSVCppRedist"
try {
DownloadOSSources -URL $OSRepoURLMSVCppRedist -SavePath $installer
}
catch {
WriteNonTerminalError -Message "Failed to download sources from: $OSRepoURLMSVCppRedist"
return 1
}

}

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. Returning $($result.ExitCode)"

return $($result.ExitCode)
}

function GetMSVCppRedistInstallInfo
{
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Checking if Microsoft Visual C++ 2015-2022 Redistributable is installed"

if ( $null -eq $(RegRead -Path "HKLM:SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" -Name "Installed") ) {

$MinimumVersionIsInstalled = $false
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "An installation of Microsoft Visual C++ 2015-2022 Redistributable (x64) (version $($OSReqsMSVCppRedistFirstVersion.ToString()) or later) was not found"
}
else {
$InstalledVersion_Major = RegRead -Path "HKLM:SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" -Name "Major"
$InstalledVersion_Minor = RegRead -Path "HKLM:SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" -Name "Minor"
$InstalledVersion_Build = RegRead -Path "HKLM:SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" -Name "Bld"
$InstalledVersion_RBuild = RegRead -Path "HKLM:SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" -Name "Rbld"
[version]$InstalledVersion = "$InstalledVersion_Major.$InstalledVersion_Minor.$InstalledVersion_Build.$InstalledVersion_RBuild"

if ($InstalledVersion -ge $OSReqsMSVCppRedistFirstVersion)
{
$MinimumVersionIsInstalled = $true
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Microsoft Visual C++ 2015-2022 Redistributable (version $($InstalledVersion.ToString())) is installed."
}
else {
$MinimumVersionIsInstalled = $false
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "An older version ($($InstalledVersion.ToString())) of Microsoft Visual C++ Redistributable (x64) was found. `
The minimum version is 2015-2022, version $($OSReqsMSVCppRedistFirstVersion.ToString()) or later)."
}
}

return $MinimumVersionIsInstalled
}