-
Notifications
You must be signed in to change notification settings - Fork 26
/
get_dependencies.ps1
46 lines (37 loc) · 1.22 KB
/
get_dependencies.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
Param(
[switch]$Clean
)
$scriptLocation = [System.IO.Path]::GetDirectoryName(
$myInvocation.MyCommand.Definition)
$ErrorActionPreference = "Stop"
# Enforce Tls1.2, as most modern websites require it
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$nugetUrl = "https://dist.nuget.org/win-x86-commandline/v4.5.1/nuget.exe"
$depsDir = "$scriptLocation\vstudio\deps"
$nugetPath = "$depsDir\nuget.exe"
$depsConfig = "$scriptLocation\packages.config"
$completeFlag = "$depsDir\complete"
function safe_exec($cmd) {
cmd /c "$cmd 2>&1"
$exitCode = $LASTEXITCODE
if ($exitCode) {
throw "Command failed: $cmd. Exit code: $exitCode"
}
}
if ($Clean -and (test-path $depsDir)) {
rm -recurse -force $depsDir
Write-Host "Cleaning up dependencies: $depsDir"
}
mkdir -force $depsDir
if (!(test-path $nugetPath)) {
Write-Host "Fetching nuget from $nugetUrl."
Invoke-WebRequest $nugetUrl -OutFile $nugetPath
}
if (!(test-path $completeFlag)) {
Write-Host "Retrieving dependencies."
safe_exec "$nugetPath install $depsConfig -OutputDirectory `"$depsDir`""
sc $completeFlag "Finished retrieving dependencies."
}
else {
write-host "Nuget dependencies already fetched."
}