Last active
October 13, 2017 14:15
-
-
Save RichieBzzzt/e1f27ae23f0e7d5fc3a651771b5c8840 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-NugetInstall { | |
param ( | |
[string] $WorkingFolder | |
, [String] $NugetPath | |
, [string] $NugetPackage | |
, [string] $PackageVersion | |
, [string] $NuGetInstallUri | |
) | |
if (-Not $WorkingFolder) { | |
Throw "Working folder needs to be set. Its blank" | |
} | |
Write-Verbose "Verbose Folder (with Verbose) : $WorkingFolder" -Verbose | |
Write-Verbose "packageVersion : $PackageVersion" -Verbose | |
Write-Warning "If PackageVersion is blank latest will be used" | |
$NugetExe = "$NugetPath\nuget.exe" | |
if (-not (Test-Path $NugetExe)) { | |
Write-Verbose "Cannot find nuget at path $NugetExe" -Verbose | |
Invoke-WebRequest $NuGetInstallUri -OutFile $NugetPath | |
if (-not (Test-Path $NugetExe)) { | |
Throw "It appears that the nuget download hasn't worked." | |
} | |
Else { | |
Write-Verbose "Nuget Downloaded!" -Verbose | |
} | |
} | |
$nugetInstallMsbuild = "&$NugetExe install $NugetPackage -ExcludeVersion -OutputDirectory $WorkingFolder" | |
if ($PackageVersion) { | |
$nugetInstallMsbuild += "-version '$PackageVersion'" | |
} | |
Write-Host $nugetInstallMsbuild -BackgroundColor White -ForegroundColor DarkGreen | |
Invoke-Expression $nugetInstallMsbuild | |
$SSDTMSbuildFolder = "$WorkingFolder\$NugetPackage" | |
if (-not (Test-Path $SSDTMSbuildFolder)) { | |
Throw "It appears that the nuget install hasn't worked, check output above to see whats going on" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment