functions/Install-ToolsPackageFromNuget.ps1

function Install-ToolsPackageFromNuget {
    [CmdletBinding()]
    param($PackagePath, $package, $subPath, $version, $environmentVariablesToSet)

    Write-Host "Installing Package $package"
    $testPath = Join-Path(Join-Path $PackagePath $package) $subPath
    
    if (-not (Test-path $testPath)) {
        $nugetparams = @("install", $package, "-ExcludeVersion", "-OutputDirectory", $PackagePath)
        if ($version) { $nugetparams += "-version", $version }
        &$nugetpath $nugetparams
    }
    if ($environmentVariablesToSet) {
        $environmentVariablesToSet | foreach-object {
            Write-verbose "Setting $_ to $testPath"
            set-item -path "env:$_" -value $testPath
        }
    }
}