|
| 1 | +using namespace Microsoft.PowerShell.Commands |
1 | 2 | [CmdletBinding()] |
2 | 3 | param( |
3 | 4 | # |
4 | | - [ValidateSet("CurrentUser", "AllUsers", "LocalTools")] |
| 5 | + [ValidateSet("CurrentUser", "AllUsers")] |
5 | 6 | $Scope = "CurrentUser" |
6 | 7 | ) |
| 8 | +[ModuleSpecification[]]$RequiredModules = Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName RequiredModules |
| 9 | +$Policy = (Get-PSRepository PSGallery).InstallationPolicy |
| 10 | +Set-PSRepository PSGallery -InstallationPolicy Trusted |
7 | 11 |
|
8 | | -Push-Location $PSScriptRoot -StackName bootstrap-stack |
9 | | - |
10 | | -# # This would probably work, if the default gallery was trusted ... |
11 | | -# Install-Module Pester -RequiredVersion 4.4.0 -Scope CurrentUser -Repository PSGallery -SkipPublisherCheck |
12 | | -# Install-Module Configuration -RequiredVersion 1.3.1 -Scope CurrentUser -Repository PSGallery -SkipPublisherCheck |
13 | | -if (!(Get-Module PSDepend -ListAvailable)) { |
14 | | - $Policy = (Get-PSRepository PSGallery).InstallationPolicy |
15 | | - try { |
16 | | - Set-PSRepository PSGallery -InstallationPolicy Trusted |
17 | | - |
18 | | - if ($Scope -eq "LocalTools") { |
19 | | - $Target = Join-Path $PSScriptRoot "Tools" |
20 | | - New-Item -Path $Target -ItemType Directory -Force |
21 | | - |
22 | | - $Env:PSModulePath += ';' + $Target |
23 | | - $PSDefaultParameterValues["Invoke-PSDepend:Target"] = $Target |
24 | | - Save-Module PSDepend -Repository PSGallery -ErrorAction Stop -Path $Target |
25 | | - } else { |
26 | | - $PSDefaultParameterValues["Invoke-PSDepend:Target"] = $Scope |
27 | | - Install-Module PSDepend -Repository PSGallery -ErrorAction Stop -Scope:$Scope |
28 | | - } |
29 | | - } finally { |
30 | | - # Make sure we didn't change anything permanently |
31 | | - Set-PSRepository PSGallery -InstallationPolicy:$Policy |
32 | | - Pop-Location -StackName bootstrap-stack |
33 | | - } |
34 | | -} |
35 | | - |
36 | | -try { |
37 | | - Write-Verbose "Updating dependencies" |
38 | | - Import-Module PSDepend -ErrorAction Stop |
39 | | - Invoke-PSDepend -Import -Force -ErrorAction Stop -Verbose |
40 | | -} catch { |
41 | | - Write-Warning "Unable to restore dependencies. Please review errors:" |
42 | | - throw |
43 | | -} |
| 12 | +$RequiredModules | Install-Module -Scope $Scope -Repository PSGallery -SkipPublisherCheck -Verbose |
| 13 | +$RequiredModules | Import-Module |
0 commit comments