Skip to content

Instantly share code, notes, and snippets.

@DamianReeves
Created April 1, 2015 12:34
Show Gist options
  • Save DamianReeves/6d372c0cf80a7200033d to your computer and use it in GitHub Desktop.
Save DamianReeves/6d372c0cf80a7200033d to your computer and use it in GitHub Desktop.
Download NuGet
param (
[string]$NuGetDir=".\.nuget\"
)
function Download-File {
param (
[string]$url,
[string]$file
)
Write-Host "Downloading $url to $file"
$downloader = new-object System.Net.WebClient
$downloader.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
$downloader.DownloadFile($url, $file)
}
$Url = 'https://nuget.org/nuget.exe'
if(![System.IO.Directory]::Exists($NuGetDir)){
[System.IO.Directory]::CreateDirectory($NuGetDir)
}
$File = Join-Path $NuGetDir "nuget.exe"
# download nuget
Download-File $url $file
@ECHO OFF
SetLocal
SET ScriptDir=%~dp0
SET NuGetDir=%ScriptDir%.nuget\
SET NuGetPath=%NuGetDir%\nuget.exe
IF NOT EXIST %NuGetPath% (
@echo "Downloading nuget.exe..."
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "& '.\Get-NuGet.ps1' '%NuGetDir%'"
)
if errorlevel 1 (
exit /b %errorlevel%
)
%NuGetPath% %*
EndLocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment