-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetNuget.ps1
More file actions
46 lines (39 loc) · 977 Bytes
/
GetNuget.ps1
File metadata and controls
46 lines (39 loc) · 977 Bytes
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
# GetNuget.ps1
#
# If nuget is not in the tools folder then it will be downloaded there.
#
# Usage:
# . .\GetNuget.ps1
# GetNuget
# GetNuget $targetDir
# GetNuget $targetDir $downloadUrl
#
function GetNuget(
$toolsDir = ("$env:LOCALAPPDATA\ps-scripts\tools\"),
$nugetDownloadUrl = "http://nuget.org/nuget.exe"
)
{
# path to nuget executable
$nugetDestPath = Join-Path -Path $toolsDir -ChildPath nuget.exe
if(!(Test-Path $toolsDir))
{
New-Item -Path $toolsDir -ItemType Directory | Out-Null
}
if(!(Test-Path $nugetDestPath))
{
Write-Host "Downloading nuget.exe to $nugetDestPath"
# download nuget
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($nugetDownloadUrl, $nugetDestPath) | Out-Null
# double check that is was written to disk
if(!(Test-Path $nugetDestPath))
{
throw 'unable to download nuget'
}
}
else
{
Write-Host "Nuget already installed at $nugetDestPath"
}
$nugetDestPath;
}