diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index 30f08c97d..ececdce84 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -439,7 +439,7 @@ function Get-AndroidPackages { [string]$AndroidSDKManagerPath ) - return (& $AndroidSDKManagerPath --list --verbose).Trim() | Foreach-Object { $_.Split()[0] } | Where-Object {$_} + return (cmd /c "$AndroidSDKManagerPath --list --verbose 2>&1").Trim() | Foreach-Object { $_.Split()[0] } | Where-Object {$_} } function Get-AndroidPackagesByName { diff --git a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 index 9cbfb1bad..fcc9a6193 100644 --- a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 @@ -53,6 +53,10 @@ function Invoke-PesterTests { if ($TestName) { $configuration.Filter.FullName = $TestName } + if ($TestFile -eq "*") { + $configuration.TestResult.Enabled = $true + $configuration.TestResult.OutputPath = "C:\image\Tests\testResults.xml" + } # Update environment variables without reboot Update-Environment diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Android.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Android.psm1 index 8953d337b..08db50303 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Android.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Android.psm1 @@ -21,7 +21,7 @@ function Get-AndroidSDKManagerPath { function Get-AndroidInstalledPackages { $androidSDKManagerPath = Get-AndroidSDKManagerPath - $androidSDKManagerList = & $androidSDKManagerPath --list_installed + $androidSDKManagerList = cmd /c "$androidSDKManagerPath --list_installed 2>&1" return $androidSDKManagerList } diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index a9ccfb8e5..3c465142a 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -271,8 +271,7 @@ function Get-VisualCPPComponents { } function Get-DacFxVersion { - cd "C:\Program Files\Microsoft SQL Server\150\DAC\bin\" - $dacfxversion = (./sqlpackage.exe /version) + $dacfxversion = & "$env:ProgramFiles\Microsoft SQL Server\150\DAC\bin\sqlpackage.exe" /version return "DacFx $dacfxversion" } diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.WebServers.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.WebServers.psm1 index 2d09c87e4..17f1f9890 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.WebServers.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.WebServers.psm1 @@ -13,8 +13,8 @@ function Get-ApacheVersion { } function Get-NginxVersion { - $nginxBinPath = Join-Path (Get-NginxPath) "\nginx" - (. $nginxBinPath -v 2>&1 | Select-String -Pattern "nginx/") -match "nginx/(?\d+\.\d+\.\d+)" | Out-Null + $nginxBinPath = Join-Path (Get-NginxPath) "nginx" + (cmd /c "$nginxBinPath -v 2>&1") -match "nginx/(?\d+\.\d+\.\d+)" | Out-Null return $Matches.Version } diff --git a/images/win/scripts/Tests/Nginx.Tests.ps1 b/images/win/scripts/Tests/Nginx.Tests.ps1 index e1e7b6f6c..8c6e7ec02 100644 --- a/images/win/scripts/Tests/Nginx.Tests.ps1 +++ b/images/win/scripts/Tests/Nginx.Tests.ps1 @@ -1,7 +1,7 @@ Describe "Nginx" { Context "Path" { It "Nginx" { - $nginxPath = Join-Path (Join-Path "C:\tools\" (Get-Item C:\tools\nginx*).Name) "\nginx" + $nginxPath = Join-Path (Join-Path "C:\tools\" (Get-Item C:\tools\nginx*).Name) "nginx" "$nginxPath -v" | Should -ReturnZeroExitCode } } diff --git a/images/win/windows2016.json b/images/win/windows2016.json index 8237c40b0..8f05537c5 100644 --- a/images/win/windows2016.json +++ b/images/win/windows2016.json @@ -264,6 +264,12 @@ "{{ template_dir }}/scripts/Tests/RunAll-Tests.ps1" ] }, + { + "type": "powershell", + "inline": [ + "if (-not (Test-Path {{user `image_folder`}}\\Tests\\testResults.xml)) { throw '{{user `image_folder`}}\\Tests\\testResults.xml not found' }" + ] + }, { "type": "powershell", "inline": [ @@ -273,6 +279,12 @@ "IMAGE_VERSION={{user `image_version`}}" ] }, + { + "type": "powershell", + "inline": [ + "if (-not (Test-Path C:\\InstalledSoftware.md)) { throw 'C:\\InstalledSoftware.md not found' }" + ] + }, { "type": "file", "source": "C:\\InstalledSoftware.md", diff --git a/images/win/windows2019.json b/images/win/windows2019.json index cc85b75d1..8ffa122f9 100644 --- a/images/win/windows2019.json +++ b/images/win/windows2019.json @@ -239,8 +239,7 @@ "{{ template_dir }}/scripts/Installers/Install-GoogleCloudSDK.ps1", "{{ template_dir }}/scripts/Installers/Install-CodeQLBundle.ps1", "{{ template_dir }}/scripts/Installers/Install-BizTalkBuildComponent.ps1", - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", - "{{ template_dir }}/scripts/Installers/Run-NGen.ps1" + "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1" ] }, { @@ -265,6 +264,12 @@ "{{ template_dir }}/scripts/Tests/RunAll-Tests.ps1" ] }, + { + "type": "powershell", + "inline": [ + "if (-not (Test-Path {{user `image_folder`}}\\Tests\\testResults.xml)) { throw '{{user `image_folder`}}\\Tests\\testResults.xml not found' }" + ] + }, { "type": "powershell", "inline": [ @@ -274,6 +279,12 @@ "IMAGE_VERSION={{user `image_version`}}" ] }, + { + "type": "powershell", + "inline": [ + "if (-not (Test-Path C:\\InstalledSoftware.md)) { throw 'C:\\InstalledSoftware.md not found' }" + ] + }, { "type": "file", "source": "C:\\InstalledSoftware.md", @@ -283,6 +294,7 @@ { "type": "powershell", "scripts": [ + "{{ template_dir }}/scripts/Installers/Run-NGen.ps1", "{{ template_dir }}/scripts/Installers/Finalize-VM.ps1" ] }, diff --git a/images/win/windows2022.json b/images/win/windows2022.json index a0ad7b76b..4d39b73e9 100644 --- a/images/win/windows2022.json +++ b/images/win/windows2022.json @@ -222,8 +222,7 @@ "{{ template_dir }}/scripts/Installers/Install-RootCA.ps1", "{{ template_dir }}/scripts/Installers/Install-MongoDB.ps1", "{{ template_dir }}/scripts/Installers/Install-CodeQLBundle.ps1", - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", - "{{ template_dir }}/scripts/Installers/Run-NGen.ps1" + "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1" ] }, { @@ -248,6 +247,12 @@ "{{ template_dir }}/scripts/Tests/RunAll-Tests.ps1" ] }, + { + "type": "powershell", + "inline": [ + "if (-not (Test-Path {{user `image_folder`}}\\Tests\\testResults.xml)) { throw '{{user `image_folder`}}\\Tests\\testResults.xml not found' }" + ] + }, { "type": "powershell", "inline": [ @@ -257,6 +262,12 @@ "IMAGE_VERSION={{user `image_version`}}" ] }, + { + "type": "powershell", + "inline": [ + "if (-not (Test-Path C:\\InstalledSoftware.md)) { throw 'C:\\InstalledSoftware.md not found' }" + ] + }, { "type": "file", "source": "C:\\InstalledSoftware.md", @@ -266,6 +277,7 @@ { "type": "powershell", "scripts": [ + "{{ template_dir }}/scripts/Installers/Run-NGen.ps1", "{{ template_dir }}/scripts/Installers/Finalize-VM.ps1" ] },