Skip to content

Commit

Permalink
Rever vsts-prequisites to not call a specific version of pester.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnybottles committed Dec 3, 2024
1 parent f16ef42 commit 791b1da
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions build/vsts-prerequisites.ps1
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 791b1da

Please sign in to comment.