I found this blog post by the Nuget team showing how you can install a nuget package programmatically. I've essentally created the same thing in my code however I want to install to the default $(SolutionDir)\packages folder.
// Install the TemplateBuilder Nuget pkg into the target project
string packageID = "TemplateBuilder";
IPackageRepository repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2");
string installPath = ""; // Somehow need to get $(SolutionDir)\packages of the target project
PackageManager packageManager = new PackageManager(repo, installPath);
packageManager.InstallPackage(packageID);Does anyone know how to set the path as the default location?