AppVeyor/AppVeyorInstall.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#---------------------------------#
# Header #
#---------------------------------#
Write-Host 'Running AppVeyor install script' -ForegroundColor Yellow

#---------------------------------#
# Install NuGet #
#---------------------------------#
Write-Host 'Installing NuGet PackageProvide'
$pkg = Install-PackageProvider -Name NuGet -Force -ErrorAction Stop
Write-Host "Installed NuGet version '$($pkg.version)'" 

#---------------------------------#
# Install Modules #
#---------------------------------#
$RequiredModules = 'PSScriptAnalyzer','Pester','xDSCResourceDesigner'
Install-Module -Name $RequiredModules -Repository PSGallery -Force -ErrorAction Stop

#---------------------------------#
# Update PSModulePath #
#---------------------------------#
Write-Host 'Updating PSModulePath for DSC resource testing'
$env:PSModulePath = $env:PSModulePath + ";" + "C:\projects"

#---------------------------------#
# Validate #
#---------------------------------#
$InstalledModules = Get-Module -Name $RequiredModules -ListAvailable
if ($InstalledModules.count -lt $RequiredModules.Count) { 
  throw "Required modules are missing."
} else {
  Write-Host 'All modules required found' -ForegroundColor Green
}