public/Add-NugetPackage.ps1

<#
.SYNOPSIS
Loads a NuGet package DLL, downloading as needed.
 
.NOTES
Install-Package isn't working for arbitrary NuGet packages, so this allows us access the main DLL
assembly and types within the package.
 
.FUNCTIONALITY
PowerShell
 
.LINK
https://www.nuget.org/
 
.EXAMPLE
Add-NugetPackage Serilog ; [Serilog.Core.Logger]::None -is [Serilog.ILogger]
 
True
#>


[CmdletBinding()] Param(
# The name of the NuGet package to load.
[Parameter(Position=0,Mandatory=$true)][string] $PackageName,
# Use this type name to test whether the package was loaded.
[Parameter(Position=1)][string] $TypeName
)
Begin
{
    $Script:BaseDir = Join-Path ($IsWindows ? $env:LOCALAPPDATA : ($env:XDG_CACHE_HOME ?? "$(Resolve-Path ~/.cache)"