-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.depend.ps1
54 lines (45 loc) · 2.06 KB
/
install.depend.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#requires -RunAsAdministrator
Write-Output 'Checking for nuget.exe'
if (-not ($NuGetPath = (Get-Command 'nuget.exe' -ErrorAction SilentlyContinue).Path)) {
if (-not (Test-Path -Path '.\bin' -ErrorAction SilentlyContinue)) {
New-Item -Path 'bin' -ItemType Directory
}
Write-Output 'nuget.exe not found, downloading into project bin path'
$NuGetPath = Resolve-Path -Path '.\bin'
$NuGetFile = Join-Path -Path $NuGetPath -ChildPath 'nuget.exe'
Invoke-WebRequest -Uri 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' -OutFile $NuGetFile
$path = [Environment]::GetEnvironmentVariable('Path', 'Machine')
$environmentPaths = $path.Split(';')
if (-not ($NuGetPath -contains $environmentPaths)) {
Write-Output 'Updating System Environment path'
$path += ";$NuGetPath"
$env:Path = $path
if (-not ($Env:BUILD_SOURCESDIRECTORY -and $Env:BUILD_BUILDNUMBER)) {
# Test for Azure build Agent - Exception calling "SetEnvironmentVariable" with "3" argument(s): "Requested registry access is not allowed."
[Environment]::SetEnvironmentVariable("Path", $path, 'Machine')
}
}
}
# Bootstrap environment
Write-Output 'Bootstrap NuGet PackageProvider'
Get-PackageProvider -Name 'NuGet' -ForceBootstrap | Out-Null
# Install PSDepend module if it is not already installed
if (-not (Get-Module -Name 'PSDepend' -ListAvailable)) {
Write-Output 'PSDepend is not yet installed, installing PSDepend'
Install-Module -Name 'PSDepend' -Scope 'CurrentUser' -Force
} else {
Write-Output 'PSDepend already installed'
}
# Install build dependencies
$psDependencyConfigPath = Join-Path -Path $PSScriptRoot -ChildPath 'install.depend.psd1'
Write-Output "Checking / resolving module dependencies from [$psDependencyConfigPath]..."
Import-Module -Name 'PSDepend'
$invokePSDependParams = @{
Path = $psDependencyConfigPath
Import = $true
Confirm = $false
Install = $true
Verbose = $false
}
Invoke-PSDepend @invokePSDependParams
Write-Output 'Finished installing all dependencies'