I want to restore nuget packages programmatically for .net core and .net Framework based on Packages.config & package references.
Any idea?
Thank you!
I want to restore nuget packages programmatically for .net core and .net Framework based on Packages.config & package references.
Any idea?
Thank you!
If using shell is ok, You may try following steps to restore nuget packages using c#.
public static void RestorePackages(string solutionPath)
{
var dir = AppDomain.CurrentDomain.BaseDirectory;
ProcessStartInfo objPI = new ProcessStartInfo($"{dir}\\nuget.exe", $"restore \"{solutionPath}\" -Verbosity quiet");
objPI.RedirectStandardError = true;
objPI.RedirectStandardOutput = true;
objPI.UseShellExecute = false;
Process objProcess = Process.Start(objPI);
string error = objProcess.StandardError.ReadToEnd();
string output = objProcess.StandardOutput.ReadToEnd();
objProcess.WaitForExit();
}