Skip to content

Instantly share code, notes, and snippets.

@RichieBzzzt
Last active October 13, 2017 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichieBzzzt/e1f27ae23f0e7d5fc3a651771b5c8840 to your computer and use it in GitHub Desktop.
Save RichieBzzzt/e1f27ae23f0e7d5fc3a651771b5c8840 to your computer and use it in GitHub Desktop.
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