Functions/Install-Nuget.ps1
<#
.SYNOPSIS Installs latest version of nuget .DESCRIPTION If not installed will download the latest copy of nuget and put it in the folder .PARAMETER fallbackNugetPath Location to store nuget .EXAMPLE Install-Nuget .NOTES FunctionName : Install-Nuget Created by : Sabin.io .LINK #> function Install-Nuget { [CmdletBinding()] param([string]$fallbackNugetPath ) Write-Verbose "Installing Nuget" if("" -eq "$fallbackNugetPath"){ if ("Unix" -eq (Get-Platform)){ $fallbackNugetPath = [IO.Path]::Combine("root","Programdata","Nuget","Nuget.exe") } else{ $fallbackNugetPath = [IO.Path]::Combine("c:\","Programdata","Nuget","Nuget.exe") } } if (Test-Path $fallbackNugetPath) { $nugetPath = $fallbackNugetPath } else { New-ToolPath (Split-Path $fallbackNugetPath -Parent); Write-Verbose "Downloading&Installing Nuget latest\" Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile $fallbackNugetPath $nugetpath = $fallbackNugetPath } Write-Verbose "Nuget found $($nugetPath)" $env:nugetPath = $nugetPath $nugetDir =[System.io.Path]::GetDirectoryName($env:nugetPath); If (($env:PATH -split [IO.Path]::PathSeparator) -notcontains $nugetDir) { $env:PATH += [IO.Path]::PathSeparator + $nugetDir } } |