Skip to content

Commit 6c10808

Browse files
Update hosting bundle to 10 (#161)
* Bump hosting bundle to version 10 * update version * Add validation to check if file is blocked
1 parent d9536ba commit 6c10808

6 files changed

Lines changed: 382 additions & 7 deletions

File tree

src/Outsystems.SetupTools/Functions/Get-OSServerPreReqs.ps1

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,27 @@ function Get-OSServerPreReqs
186186

187187
# Check .NET Core / .NET Windows Server Hosting version
188188
$fullVersion = [version]"$MajorVersion.$MinorVersion.$PatchVersion.0"
189-
if ($fullVersion -ge [version]"11.27.0.0")
189+
if ($fullVersion -ge [version]"11.40.2.0")
190+
{
191+
$requireDotNetHostingBundle6 = $false
192+
$requireDotNetHostingBundle8 = $false
193+
$requireDotNetHostingBundle10 = $true
194+
}
195+
196+
elseif ($fullVersion -ge [version]"11.27.0.0")
190197
{
191198
# Here means that minor and patch version were specified and we are equal or above version 11.27.0.0
192199
# We install .NET 8.0 only
193200
$requireDotNetHostingBundle6 = $false
194201
$requireDotNetHostingBundle8 = $true
202+
$requireDotNetHostingBundle10 = $false
195203
}
196204
else
197205
{
198-
# Here means that minor and patch version were specified and we are below version 11.27.0.0
206+
# Here means that minor and patch version were not specified or we are below version 11.27.0.0
199207
$requireDotNetHostingBundle6 = $true
200208
$requireDotNetHostingBundle8 = $true
209+
$requireDotNetHostingBundle10 = $true
201210
}
202211

203212
if ($fullVersion -lt [version]"11.35.0.0")
@@ -285,6 +294,45 @@ function Get-OSServerPreReqs
285294
}
286295
}
287296

297+
if ($requireDotNetHostingBundle10) {
298+
$RequirementStatuses += CreateRequirementStatus -Title ".NET 10.0 Windows Server Hosting" `
299+
-ScriptBlock `
300+
{
301+
$Status = $False
302+
foreach ($version in GetDotNetHostingBundleVersions)
303+
{
304+
# Check version 10.0
305+
if (([version]$version).Major -eq 10 -and ([version]$version) -ge [version]$script:OSDotNetHostingBundleReq['10']['Version']) {
306+
$Status = $True
307+
}
308+
}
309+
$OKMessages = @("Minimum .NET 10.0.2 Windows Server Hosting found.")
310+
$NOKMessages = @("Minimum .NET 10.0.2 Windows Server Hosting not found.")
311+
$IISStatus = $True
312+
313+
if (Get-Command Get-WebGlobalModule -errorAction SilentlyContinue)
314+
{
315+
$aspModules = Get-WebGlobalModule | Where-Object { $_.Name -eq "aspnetcoremodulev2" }
316+
if ($Status)
317+
{
318+
# Check if IIS can find ASP.NET modules
319+
if ($aspModules.Count -lt 1)
320+
{
321+
$Status = $False
322+
$IISStatus = $False
323+
$NOKMessages = @("IIS can't find ASP.NET modules")
324+
}
325+
else
326+
{
327+
$IISStatus = $True
328+
}
329+
}
330+
}
331+
332+
333+
return $(CreateResult -Status $Status -IISStatus $IISStatus -OKMessages $OKMessages -NOKMessages $NOKMessages)
334+
}
335+
}
288336

289337
$RequirementStatuses += CreateRequirementStatus -Title "Windows Features" `
290338
-ScriptBlock `

src/Outsystems.SetupTools/Functions/Install-OSServerPreReqs.ps1

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,30 @@ function Install-OSServerPreReqs
187187
$installBuildTools = $false
188188
}
189189

190-
if ($fullVersion -ge [version]"11.27.0.0")
190+
if ($fullVersion -ge [version]"11.40.2.0")
191+
{
192+
# Here means that minor and patch version were specified and we are equal or above version 11.27.0.0
193+
# We install .NET 8.0 only
194+
$installDotNetHostingBundle6 = $false
195+
$installDotNetHostingBundle8 = $false
196+
$installDotNetHostingBundle10 = $true
197+
$mostRecentHostingBundleVersion = [version]$script:OSDotNetHostingBundleReq['10']['Version']
198+
}
199+
elseif ($fullVersion -ge [version]"11.27.0.0")
191200
{
192201
# Here means that minor and patch version were specified and we are equal or above version 11.27.0.0
193202
# We install .NET 8.0 only
194203
$installDotNetHostingBundle6 = $false
195204
$installDotNetHostingBundle8 = $true
205+
$installDotNetHostingBundle10 = $false
196206
$mostRecentHostingBundleVersion = [version]$script:OSDotNetHostingBundleReq['8']['Version']
197207
}
198208
else
199209
{
200-
# Here means that minor and patch version were specified and we are below version 11.27.0.0
210+
# Here means that minor and patch version were not specified or we are below version 11.27.0.0
201211
$installDotNetHostingBundle6 = $true
202212
$installDotNetHostingBundle8 = $false
213+
$installDotNetHostingBundle10 = $false
203214
$mostRecentHostingBundleVersion = [version]$script:OSDotNetHostingBundleReq['6']['Version']
204215
}
205216

@@ -213,6 +224,10 @@ function Install-OSServerPreReqs
213224
if (([version]$version).Major -eq 8 -and ([version]$version) -ge [version]$script:OSDotNetHostingBundleReq['8']['Version']) {
214225
$installDotNetHostingBundle8 = $false
215226
}
227+
# Check .NET 10.0
228+
if (([version]$version).Major -eq 10 -and ([version]$version) -ge [version]$script:OSDotNetHostingBundleReq['10']['Version']) {
229+
$installDotNetHostingBundle10 = $false
230+
}
216231
}
217232

218233
if ($installDotNetHostingBundle6) {
@@ -221,7 +236,9 @@ function Install-OSServerPreReqs
221236
if ($installDotNetHostingBundle8) {
222237
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"
223238
}
224-
239+
if ($installDotNetHostingBundle10) {
240+
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Minimum .NET Windows Server Hosting version 10.0.2 for OutSystems $MajorVersion not found. We will try to download and install the latest .NET Windows Server Hosting bundle"
241+
}
225242

226243
# Check .NET version
227244
if ($(GetDotNet4Version) -lt $script:OSDotNetReqForMajor[$MajorVersion]['Value'])
@@ -455,6 +472,63 @@ function Install-OSServerPreReqs
455472
}
456473
}
457474

475+
# Install .NET Windows Server Hosting bundle version 10
476+
if ($installDotNetHostingBundle10)
477+
{
478+
try
479+
{
480+
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Installing .NET 10.0 Windows Server Hosting bundle"
481+
$exitCode = InstallDotNetHostingBundle -MajorVersion '10' -Sources $SourcePath -SkipRuntimePackages $SkipRuntimePackages
482+
}
483+
catch [System.IO.FileNotFoundException]
484+
{
485+
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Exception $_.Exception -Stream 3 -Message ".NET 10.0 installer not found"
486+
WriteNonTerminalError -Message ".NET 10.0 installer not found"
487+
488+
$installResult.Success = $false
489+
$installResult.ExitCode = -1
490+
$installResult.Message = '.NET 10.0 installer not found'
491+
492+
return $installResult
493+
}
494+
catch
495+
{
496+
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Exception $_.Exception -Stream 3 -Message "Error downloading or starting the .NET 10.0 installation"
497+
WriteNonTerminalError -Message "Error downloading or starting the .NET 10.0 installation"
498+
499+
$installResult.Success = $false
500+
$installResult.ExitCode = -1
501+
$installResult.Message = 'Error downloading or starting the .NET 10.0 installation'
502+
503+
return $installResult
504+
}
505+
506+
switch ($exitCode)
507+
{
508+
0
509+
{
510+
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message ".NET 10.0 Windows Server Hosting bundle successfully installed."
511+
}
512+
513+
{ $_ -in 3010, 3011 }
514+
{
515+
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message ".NET 10.0 Windows Server Hosting bundle successfully installed but a reboot is needed. Exit code: $exitCode"
516+
$installResult.RebootNeeded = $true
517+
}
518+
519+
default
520+
{
521+
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 3 -Message "Error installing .NET 10.0 Windows Server Hosting bundle. Exit code: $exitCode"
522+
WriteNonTerminalError -Message "Error installing .NET 10.0 Windows Server Hosting bundle. Exit code: $exitCode"
523+
524+
$installResult.Success = $false
525+
$installResult.ExitCode = $exitCode
526+
$installResult.Message = 'Error installing .NET 10.0 Windows Server Hosting bundle'
527+
528+
return $installResult
529+
}
530+
}
531+
}
458532

459533
if ($mostRecentHostingBundleVersion -and $RemovePreviousHostingBundlePackages)
460534
{

src/Outsystems.SetupTools/Lib/Common.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,32 @@ function ValidateMinimumRequiredVersion()
367367

368368
return $true
369369
}
370+
371+
# Checks if the ZoneId (not AppZoneId) is different than 0 (non local)
372+
# ZoneId identifies the general security zone (e.g., Internet, Intranet) from which a file was downloaded, determining how strictly Windows treats the file.
373+
# AppZoneId is a specialized, often temporary, identifier used by applications (like Microsoft SmartScreen) to manage trust exceptions after a user has decided to "Run" a file, often replacing or bypassing the original ZoneId to prevent future security prompts for that specific file
374+
# It is possible to test this by modifying alternate data stream Set-Content -Path <file> -Stream Zone.Identifier -Value "[ZoneTransfer]`nZoneId=1"
375+
function CheckIfFileIsBlocked([string]$Path)
376+
{
377+
$fileAlternateDataStream = Get-Content $Path -Stream Zone.Identifier
378+
if ($fileAlternateDataStream)
379+
{
380+
$ZoneId = $fileAlternateDataStream -match "^ZoneId=[0-9]"
381+
if ($ZoneId)
382+
{
383+
$Id = $ZoneId -replace "ZoneId=" , ""
384+
385+
return $($Id[0] -ne 0)
386+
}
387+
}
388+
389+
return $false
390+
}
391+
392+
function LogIfFileIsBlocked([string]$Function, [string]$Path)
393+
{
394+
if ($(CheckIfFileIsBlocked -Path $Path))
395+
{
396+
LogMessage -Function $Function -Phase 1 -Stream 1 -Message "$($Path) might be blocked (ZoneId <> 0). Depending on the windows policies of the machine the installation might get stuck."
397+
}
398+
}

src/Outsystems.SetupTools/Lib/Constants.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ $OSDotNetHostingBundleReq = @{
111111
ToInstallDownloadURL = 'https://download.visualstudio.microsoft.com/download/pr/2a7ae819-fbc4-4611-a1ba-f3b072d4ea25/32f3b931550f7b315d9827d564202eeb/dotnet-hosting-8.0.0-win.exe'
112112
InstallerName = 'DotNet_WindowsHosting_8.exe'
113113
}
114+
'10' = @{
115+
Version = '10.0.2'
116+
ToInstallDownloadURL = 'https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/10.0.2/dotnet-hosting-10.0.2-win.exe'
117+
InstallerName = 'DotNet_WindowsHosting_10.exe'
118+
}
114119
}
115120

116121
# .NET Core Uninstall Tool related

src/Outsystems.SetupTools/Lib/PlatformSetup.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,14 @@ function InstallDotNet([string]$Sources, [string]$URL)
135135
{
136136
$installer = "$Sources\DotNet.exe"
137137
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local file: $installer"
138+
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
138139
}
139140
# If Windows is set to hide file extensions from file names, the file could have been stored with double extension by mistake.
140141
elseif (Test-Path "$Sources\DotNet.exe.exe")
141142
{
142143
$installer = "$Sources\DotNet.exe.exe"
143144
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local fallback file: $installer"
145+
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
144146
}
145147
else {
146148
throw [System.IO.FileNotFoundException] "DotNet.exe not found."
@@ -346,12 +348,14 @@ function InstallBuildTools([string]$Sources)
346348
{
347349
$installer = "$Sources\BuildTools_Full.exe"
348350
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local file: $installer"
351+
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
349352
}
350353
# If Windows is set to hide file extensions from file names, the file could have been stored with double extension by mistake.
351354
elseif (Test-Path "$Sources\BuildTools_Full.exe.exe")
352355
{
353356
$installer = "$Sources\BuildTools_Full.exe.exe"
354357
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local fallback file: $installer"
358+
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
355359
}
356360
else {
357361
throw [System.IO.FileNotFoundException] "BuildTools_Full.exe not found."
@@ -380,12 +384,14 @@ function InstallDotNetHostingBundle([string]$MajorVersion, [string]$Sources, [bo
380384
{
381385
$installer = "$Sources\$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName'])"
382386
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local file: $installer"
387+
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
383388
}
384389
# If Windows is set to hide file extensions from file names, the file could have been stored with double extension by mistake.
385390
elseif (Test-Path "$Sources\$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName']).exe")
386391
{
387392
$installer = "$($script:OSDotNetHostingBundleReq[$MajorVersion]['InstallerName']).exe"
388393
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local fallback file: $installer"
394+
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
389395
}
390396
else {
391397
throw [System.IO.FileNotFoundException] "$installerName.exe not found."
@@ -419,12 +425,14 @@ function InstallDotNetCoreUninstallTool([string]$MajorVersion, [string]$Sources)
419425
{
420426
$installer = "$Sources\$($script:OSDotNetCoreUninstallReq[$MajorVersion]['InstallerName'])"
421427
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local file: $installer"
428+
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
422429
}
423430
# If Windows is set to hide file extensions from file names, the file could have been stored with double extension by mistake.
424431
elseif (Test-Path "$Sources\$($script:OSDotNetCoreUninstallReq[$MajorVersion]['InstallerName']).exe")
425432
{
426433
$installer = "$($script:OSDotNetCoreUninstallReq[$MajorVersion]['InstallerName']).exe"
427434
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Using local fallback file: $installer"
435+
LogIfFileIsBlocked -Function $($MyInvocation.Mycommand) -Path $installer
428436
}
429437
else {
430438
throw [System.IO.FileNotFoundException] "$installerName.exe not found."
@@ -779,8 +787,8 @@ Function ExecuteCommand([string]$CommandPath, [string]$WorkingDirectory, [string
779787
$Process = New-Object System.Diagnostics.Process
780788
$Process.StartInfo = $ProcessInfo
781789
$Process.Start() | Out-Null
782-
$Process.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::Idle
783-
790+
$Process.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::Idle
791+
784792
if ($OnLogEvent)
785793
{
786794
do

0 commit comments

Comments
 (0)