Skip to content

Commit 1fbfcff

Browse files
R11BCT-110 - re-add the code that install all .Net Hosting Bundle versions (#164)
1 parent c641417 commit 1fbfcff

2 files changed

Lines changed: 45 additions & 36 deletions

File tree

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ function Install-OSServerPreReqs
107107
{
108108
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Minor version was not specified. Minimum version will be set to 23."
109109
$MinorVersion = "23"
110+
$UnspecifiedMinor = $true
110111
}
111112
}
112113

@@ -187,7 +188,16 @@ function Install-OSServerPreReqs
187188
$installBuildTools = $false
188189
}
189190

190-
if ($fullVersion -ge [version]"11.40.2.0")
191+
if ($UnspecifiedMinor)
192+
{
193+
# Here means that minor and patch version were not specified
194+
# We install all version possible
195+
$installDotNetHostingBundle6 = $true
196+
$installDotNetHostingBundle8 = $true
197+
$installDotNetHostingBundle10 = $true
198+
# We do not set recent hosting bundle because we don't know the version we are to uninstall the others
199+
}
200+
elseif ($fullVersion -ge [version]"11.40.2.0")
191201
{
192202
# Here means that minor and patch version were specified and we are equal or above version 11.27.0.0
193203
# We install .NET 8.0 only
@@ -207,7 +217,7 @@ function Install-OSServerPreReqs
207217
}
208218
else
209219
{
210-
# Here means that minor and patch version were not specified or we are below version 11.27.0.0
220+
# Here means that we are below version 11.27.0.0
211221
$installDotNetHostingBundle6 = $true
212222
$installDotNetHostingBundle8 = $false
213223
$installDotNetHostingBundle10 = $false

test/unit/Install-OSServerPreReqs.Tests.ps1

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ InModuleScope -ModuleName OutSystems.SetupTools {
5353
It 'Should run the BuildTools installation' { Assert-MockCalled @assRunInstallBuildTools }
5454
It 'Should install the windows features installation' { Assert-MockCalled @assRunInstallWindowsFeatures }
5555
It 'Should run the .NET 6.0 Hosting Bundle installation' { Assert-MockCalled @assRunInstallDotNetHostingBundle }
56-
It 'Should not run the .NET 8.0 Hosting Bundle installation' { Assert-MockCalled @assNotRunInstallDotNetHostingBundle8 }
57-
It 'Should not run the .NET 10.0 Hosting Bundle installation' { Assert-MockCalled @assNotRunInstallDotNetHostingBundle10 }
56+
It 'Should run the .NET 8.0 Hosting Bundle installation' { Assert-MockCalled @assRunInstallDotNetHostingBundle8 }
57+
It 'Should run the .NET 10.0 Hosting Bundle installation' { Assert-MockCalled @assRunInstallDotNetHostingBundle10 }
5858
It 'Should configure the WMI service' { Assert-MockCalled @assRunConfigureServiceWMI }
5959
It 'Should configure the Windows search service' { Assert-MockCalled @assRunConfigureServiceWindowsSearch }
6060
It 'Should disable the FIPS' { Assert-MockCalled @assRunDisableFIPS }
@@ -63,7 +63,7 @@ InModuleScope -ModuleName OutSystems.SetupTools {
6363
$result.Success | Should Be $true
6464
$result.RebootNeeded | Should Be $false
6565
$result.ExitCode | Should Be 0
66-
$result.Message | Should Be 'Outsystems platform server pre-requisites successfully installed'
66+
$result.Message | Should Be 'OutSystems platform server pre-requisites successfully installed'
6767
}
6868
It 'Should not output an error' { $err.Count | Should Be 0 }
6969
It 'Should not throw' { { Install-OSServerPreReqs -MajorVersion '11' -ErrorAction SilentlyContinue } | Should Not throw }
@@ -121,7 +121,7 @@ InModuleScope -ModuleName OutSystems.SetupTools {
121121

122122
Mock GetMSBuildToolsInstallInfo { return @{ 'HasMSBuild2015' = $True; 'HasMSBuild2017' = $False; 'LatestVersionInstalled' = 'MS Build Tools 2015'; 'RebootNeeded' = $False } }
123123
Mock GetDotNet4Version { return 461808 }
124-
Mock GetDotNetHostingBundleVersions { return @('6.0.6', '8.0.0') }
124+
Mock GetDotNetHostingBundleVersions { return @('6.0.6', '8.0.0', '10.0.2') }
125125

126126
$result = Install-OSServerPreReqs -MajorVersion '11' -ErrorVariable err -ErrorAction SilentlyContinue
127127

@@ -233,12 +233,12 @@ InModuleScope -ModuleName OutSystems.SetupTools {
233233
Assert-MockCalled @assRunInstallDotNet
234234
Assert-MockCalled @assRunInstallBuildTools
235235
Assert-MockCalled @assRunInstallDotNetHostingBundle
236+
Assert-MockCalled @assRunInstallDotNetHostingBundle8
237+
Assert-MockCalled @assRunInstallDotNetHostingBundle10
236238
Assert-MockCalled @assRunInstallWindowsFeatures
237239
}
238240

239241
It 'Should NOT run the next actions' {
240-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle8
241-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle10
242242
Assert-MockCalled @assNotRunConfigureServiceWMI
243243
Assert-MockCalled @assNotRunConfigureServiceWindowsSearch
244244
Assert-MockCalled @assNotRunDisableFIPS
@@ -263,12 +263,12 @@ InModuleScope -ModuleName OutSystems.SetupTools {
263263
Assert-MockCalled @assRunInstallDotNet
264264
Assert-MockCalled @assRunInstallBuildTools
265265
Assert-MockCalled @assRunInstallDotNetHostingBundle
266+
Assert-MockCalled @assRunInstallDotNetHostingBundle8
267+
Assert-MockCalled @assRunInstallDotNetHostingBundle10
266268
Assert-MockCalled @assRunInstallWindowsFeatures
267269
}
268270

269271
It 'Should NOT run the next actions' {
270-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle8
271-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle10
272272
Assert-MockCalled @assNotRunConfigureServiceWMI
273273
Assert-MockCalled @assNotRunConfigureServiceWindowsSearch
274274
Assert-MockCalled @assNotRunDisableFIPS
@@ -293,6 +293,8 @@ InModuleScope -ModuleName OutSystems.SetupTools {
293293
Assert-MockCalled @assRunInstallDotNet
294294
Assert-MockCalled @assRunInstallBuildTools
295295
Assert-MockCalled @assRunInstallDotNetHostingBundle
296+
Assert-MockCalled @assRunInstallDotNetHostingBundle8
297+
Assert-MockCalled @assRunInstallDotNetHostingBundle10
296298
Assert-MockCalled @assRunInstallWindowsFeatures
297299
Assert-MockCalled @assRunConfigureServiceWMI
298300
Assert-MockCalled @assRunConfigureServiceWindowsSearch
@@ -301,8 +303,6 @@ InModuleScope -ModuleName OutSystems.SetupTools {
301303
}
302304

303305
It 'Should NOT run the next actions' {
304-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle8
305-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle10
306306
}
307307

308308
It 'Should return the right result' {
@@ -324,12 +324,12 @@ InModuleScope -ModuleName OutSystems.SetupTools {
324324
Assert-MockCalled @assRunInstallDotNet
325325
Assert-MockCalled @assRunInstallBuildTools
326326
Assert-MockCalled @assRunInstallDotNetHostingBundle
327+
Assert-MockCalled @assRunInstallDotNetHostingBundle8
328+
Assert-MockCalled @assRunInstallDotNetHostingBundle10
327329
Assert-MockCalled @assRunInstallWindowsFeatures
328330
}
329331

330332
It 'Should NOT run the next actions' {
331-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle8
332-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle10
333333
Assert-MockCalled @assNotRunConfigureServiceWMI
334334
Assert-MockCalled @assNotRunConfigureServiceWindowsSearch
335335
Assert-MockCalled @assNotRunDisableFIPS
@@ -441,6 +441,8 @@ InModuleScope -ModuleName OutSystems.SetupTools {
441441
Assert-MockCalled @assRunInstallDotNet
442442
Assert-MockCalled @assRunInstallBuildTools
443443
Assert-MockCalled @assRunInstallDotNetHostingBundle
444+
Assert-MockCalled @assRunInstallDotNetHostingBundle8
445+
Assert-MockCalled @assRunInstallDotNetHostingBundle10
444446
Assert-MockCalled @assRunInstallWindowsFeatures
445447
Assert-MockCalled @assRunConfigureServiceWMI
446448
Assert-MockCalled @assRunConfigureServiceWindowsSearch
@@ -449,8 +451,6 @@ InModuleScope -ModuleName OutSystems.SetupTools {
449451
}
450452

451453
It 'Should NOT run the next actions' {
452-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle8
453-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle10
454454
}
455455

456456
It 'Should return the right result' {
@@ -532,17 +532,16 @@ InModuleScope -ModuleName OutSystems.SetupTools {
532532
Assert-MockCalled @assRunInstallDotNet
533533
Assert-MockCalled @assRunInstallBuildTools
534534
Assert-MockCalled @assRunInstallDotNetHostingBundle
535+
Assert-MockCalled @assRunInstallDotNetHostingBundle8
536+
Assert-MockCalled @assRunInstallDotNetHostingBundle10
535537
Assert-MockCalled @assRunInstallWindowsFeatures
536538
Assert-MockCalled @assRunConfigureServiceWMI
537539
Assert-MockCalled @assRunConfigureServiceWindowsSearch
538540
Assert-MockCalled @assRunDisableFIPS
539541
Assert-MockCalled @assRunConfigureWindowsEventLog
540542
}
541543

542-
# These are here not because the hosting bundle is not executed but because these version do not run
543544
It 'Should NOT run the next actions' {
544-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle8
545-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle10
546545
}
547546

548547
It 'Should return the right result' {
@@ -830,7 +829,7 @@ InModuleScope -ModuleName OutSystems.SetupTools {
830829
Context 'When .NET 6.0 reports a reboot' {
831830

832831
Mock -CommandName InstallDotNetHostingBundle -ParameterFilter { $MajorVersion -eq "6" } -MockWith { return 3010 }
833-
$result = Install-OSServerPreReqs -MajorVersion '11' -ErrorVariable err -ErrorAction SilentlyContinue
832+
$result = Install-OSServerPreReqs -MajorVersion '11' -MinorVersion '23' -ErrorVariable err -ErrorAction SilentlyContinue
834833

835834
It 'Should run the next actions' {
836835
Assert-MockCalled @assRunInstallDotNet
@@ -855,7 +854,7 @@ InModuleScope -ModuleName OutSystems.SetupTools {
855854
$result.Message | Should Be 'Outsystems platform server pre-requisites successfully installed but a reboot is required'
856855
}
857856
It 'Should not output an error' { $err.Count | Should Be 0 }
858-
It 'Should not throw' { { Install-OSServerPreReqs -MajorVersion '11' -ErrorAction SilentlyContinue } | Should Not throw }
857+
It 'Should not throw' { { Install-OSServerPreReqs -MajorVersion '11' -MinorVersion '23' -ErrorAction SilentlyContinue } | Should Not throw }
859858
}
860859

861860
Context 'When .NET 10.0 reports an error' {
@@ -958,13 +957,13 @@ InModuleScope -ModuleName OutSystems.SetupTools {
958957
Assert-MockCalled @assRunInstallDotNet
959958
Assert-MockCalled @assRunInstallBuildTools
960959
Assert-MockCalled @assRunInstallDotNetHostingBundle
960+
Assert-MockCalled @assRunInstallDotNetHostingBundle8
961+
Assert-MockCalled @assRunInstallDotNetHostingBundle10
961962
Assert-MockCalled @assRunInstallWindowsFeatures
962963
Assert-MockCalled @assRunConfigureServiceWMI
963964
}
964965

965966
It 'Should NOT run the next actions' {
966-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle8
967-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle10
968967
Assert-MockCalled @assNotRunConfigureServiceWindowsSearch
969968
Assert-MockCalled @assNotRunDisableFIPS
970969
Assert-MockCalled @assNotRunConfigureWindowsEventLog
@@ -989,14 +988,14 @@ InModuleScope -ModuleName OutSystems.SetupTools {
989988
Assert-MockCalled @assRunInstallDotNet
990989
Assert-MockCalled @assRunInstallBuildTools
991990
Assert-MockCalled @assRunInstallDotNetHostingBundle
991+
Assert-MockCalled @assRunInstallDotNetHostingBundle8
992+
Assert-MockCalled @assRunInstallDotNetHostingBundle10
992993
Assert-MockCalled @assRunInstallWindowsFeatures
993994
Assert-MockCalled @assRunConfigureServiceWMI
994995
Assert-MockCalled @assRunConfigureServiceWindowsSearch
995996
}
996997

997998
It 'Should NOT run the next actions' {
998-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle8
999-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle10
1000999
Assert-MockCalled @assNotRunDisableFIPS
10011000
Assert-MockCalled @assNotRunConfigureWindowsEventLog
10021001
}
@@ -1020,15 +1019,15 @@ InModuleScope -ModuleName OutSystems.SetupTools {
10201019
Assert-MockCalled @assRunInstallDotNet
10211020
Assert-MockCalled @assRunInstallBuildTools
10221021
Assert-MockCalled @assRunInstallDotNetHostingBundle
1022+
Assert-MockCalled @assRunInstallDotNetHostingBundle8
1023+
Assert-MockCalled @assRunInstallDotNetHostingBundle10
10231024
Assert-MockCalled @assRunInstallWindowsFeatures
10241025
Assert-MockCalled @assRunConfigureServiceWMI
10251026
Assert-MockCalled @assRunConfigureServiceWindowsSearch
10261027
Assert-MockCalled @assRunDisableFIPS
10271028
}
10281029

10291030
It 'Should NOT run the next actions' {
1030-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle8
1031-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle10
10321031
Assert-MockCalled @assNotRunConfigureWindowsEventLog
10331032
}
10341033

@@ -1052,6 +1051,8 @@ InModuleScope -ModuleName OutSystems.SetupTools {
10521051
Assert-MockCalled @assRunInstallDotNet
10531052
Assert-MockCalled @assRunInstallBuildTools
10541053
Assert-MockCalled @assRunInstallDotNetHostingBundle
1054+
Assert-MockCalled @assRunInstallDotNetHostingBundle8
1055+
Assert-MockCalled @assRunInstallDotNetHostingBundle10
10551056
Assert-MockCalled @assRunInstallWindowsFeatures
10561057
Assert-MockCalled @assRunConfigureServiceWMI
10571058
Assert-MockCalled @assRunConfigureServiceWindowsSearch
@@ -1060,8 +1061,6 @@ InModuleScope -ModuleName OutSystems.SetupTools {
10601061
}
10611062

10621063
It 'Should NOT run the next actions' {
1063-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle8
1064-
Assert-MockCalled @assNotRunInstallDotNetHostingBundle10
10651064
}
10661065

10671066
It 'Should return the right result' {
@@ -1197,8 +1196,8 @@ InModuleScope -ModuleName OutSystems.SetupTools {
11971196
It 'Should run the BuildTools installation' { Assert-MockCalled @assRunInstallBuildTools }
11981197
It 'Should install the windows features installation' { Assert-MockCalled @assRunInstallWindowsFeatures }
11991198
It 'Should run the .NET 6.0 Hosting Bundle installation' { Assert-MockCalled @assRunInstallDotNetHostingBundle }
1200-
It 'Should not run the .NET 8.0 Hosting Bundle installation' { Assert-MockCalled @assNotRunInstallDotNetHostingBundle8 }
1201-
It 'Should not run the .NET 10.0 Hosting Bundle installation' { Assert-MockCalled @assNotRunInstallDotNetHostingBundle10 }
1199+
It 'Should run the .NET 8.0 Hosting Bundle installation' { Assert-MockCalled @assRunInstallDotNetHostingBundle8 }
1200+
It 'Should run the .NET 10.0 Hosting Bundle installation' { Assert-MockCalled @assRunInstallDotNetHostingBundle10 }
12021201
It 'Should not run the .NET Core Uninstall Tool installation' { Assert-MockCalled @assNotRunInstallDotNetCoreUninstallTool }
12031202
It 'Should configure the WMI service' { Assert-MockCalled @assRunConfigureServiceWMI }
12041203
It 'Should configure the Windows search service' { Assert-MockCalled @assRunConfigureServiceWindowsSearch }
@@ -1214,17 +1213,17 @@ InModuleScope -ModuleName OutSystems.SetupTools {
12141213
It 'Should not throw' { { Install-OSServerPreReqs -MajorVersion '11' -ErrorVariable err -ErrorAction SilentlyContinue } | Should Not throw }
12151214
}
12161215

1217-
Context 'When trying to install prerequisites for a OS 11 version without passing the optional Minor and Patch Versions and with RemovePreviousHostingBundlePackages flag active' {
1216+
Context 'When trying to install prerequisites for a OS 11 version without passing the optional Minor and Patch Versions and with RemovePreviousHostingBundlePackages flag active.' {
12181217

12191218
$result = Install-OSServerPreReqs -MajorVersion '11' -RemovePreviousHostingBundlePackages $true -ErrorVariable err -ErrorAction SilentlyContinue
1220-
1219+
# Without being called with a specific version, .Net Core Uninstall tool should not run even if called with the flag to true
12211220
It 'Should run the .NET installation' { Assert-MockCalled @assRunInstallDotNet }
12221221
It 'Should run the BuildTools installation' { Assert-MockCalled @assRunInstallBuildTools }
12231222
It 'Should install the windows features installation' { Assert-MockCalled @assRunInstallWindowsFeatures }
12241223
It 'Should run the .NET 6.0 Hosting Bundle installation' { Assert-MockCalled @assRunInstallDotNetHostingBundle }
1225-
It 'Should not run the .NET 8.0 Hosting Bundle installation' { Assert-MockCalled @assNotRunInstallDotNetHostingBundle8 }
1226-
It 'Should not run the .NET 10.0 Hosting Bundle installation' { Assert-MockCalled @assNotRunInstallDotNetHostingBundle10 }
1227-
It 'Should run the .NET Core Uninstall Tool installation' { Assert-MockCalled @assRunInstallDotNetCoreUninstallTool }
1224+
It 'Should run the .NET 8.0 Hosting Bundle installation' { Assert-MockCalled @assRunInstallDotNetHostingBundle8 }
1225+
It 'Should run the .NET 10.0 Hosting Bundle installation' { Assert-MockCalled @assRunInstallDotNetHostingBundle10 }
1226+
It 'Should Not run the .NET Core Uninstall Tool installation' { Assert-MockCalled @assNotRunInstallDotNetCoreUninstallTool }
12281227
It 'Should configure the WMI service' { Assert-MockCalled @assRunConfigureServiceWMI }
12291228
It 'Should configure the Windows search service' { Assert-MockCalled @assRunConfigureServiceWindowsSearch }
12301229
It 'Should disable the FIPS' { Assert-MockCalled @assRunDisableFIPS }

0 commit comments

Comments
 (0)