From 791b1daf04a55ee05ae369072ee8301ec3e15041 Mon Sep 17 00:00:00 2001 From: Jonathan Butler Date: Tue, 3 Dec 2024 18:43:39 -0500 Subject: [PATCH] Rever vsts-prequisites to not call a specific version of pester. --- build/vsts-prerequisites.ps1 | 44 ++++++++++++++---------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/build/vsts-prerequisites.ps1 b/build/vsts-prerequisites.ps1 index 5e401c3..c72baa2 100644 --- a/build/vsts-prerequisites.ps1 +++ b/build/vsts-prerequisites.ps1 @@ -1,40 +1,30 @@ -param ( +#vsts-prequisites.ps1 + +param ( [string] $Repository = 'PSGallery' ) -$modules = @( - @{ Name = "Pester"; Version = "5.6.1" }, - "PSFramework", - "PSModuleDevelopment" -) +$modules = @("Pester", "PSFramework", "PSModuleDevelopment") + +# Automatically add missing dependencies +# TODO: uncomment this block of code below and fix RobustCloudCommand error. -# Load required modules from Hawk.psd1 $data = Import-PowerShellDataFile -Path "$PSScriptRoot\..\Hawk\Hawk.psd1" foreach ($dependency in $data.RequiredModules) { - # Handle string dependencies if ($dependency -is [string]) { - if (-not ($modules -contains $dependency)) { - $modules += @{ Name = $dependency; Version = "" } - } + if ($modules -contains $dependency) { continue } + $modules += $dependency } - # Handle hashtable dependencies - elseif ($dependency -is [hashtable]) { - if (-not ($modules -contains $dependency.ModuleName)) { - $modules += @{ Name = $dependency.ModuleName; Version = $dependency.RequiredVersion } - } + else { + if ($modules -contains $dependency.ModuleName) { continue } + $modules += $dependency.ModuleName } } -# Install and import modules foreach ($module in $modules) { - try { - $moduleName = $module.Name - $moduleVersion = $module.Version - Write-Output "Installing $moduleName" - Install-Module -Name $moduleName -RequiredVersion $moduleVersion -Force -SkipPublisherCheck -Repository $Repository - Import-Module -Name $moduleName -Force -PassThru - } catch { - Write-Error "Failed to install or import module: $($module.Name). Error: $_" - } -} + # Write-Output "Installing module: $module" + Write-Output "Installing $module" + Install-Module $module -Force -SkipPublisherCheck -Repository $Repository + Import-Module $module -Force -PassThru +} \ No newline at end of file