-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNuGetPackagesInstaller.cs
38 lines (34 loc) · 1.24 KB
/
NuGetPackagesInstaller.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
namespace RCLTStarter
{
class NuGetPackagesInstaller
{
readonly IEnumerable<string> m_Sources;
readonly string m_InstallDir;
public NuGetPackagesInstaller(IEnumerable<string> sources, string installDir)
{
m_Sources = sources;
m_InstallDir = installDir;
}
public List<string> InstallPackages(IEnumerable<PackageInfo> packages)
{
return packages.Select(InstallPackage).ToList();
}
private string InstallPackage(PackageInfo packageInfo)
{
var args = new List<string>();
args.Add("install");
args.AddRange(m_Sources.Select(source => $"-source {source}"));
args.Add($"{packageInfo.Id} -version {packageInfo.Version}");
args.Add($"-OutputDirectory \"{m_InstallDir}\"");
args.Add("-ExcludeVersion");
var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Process.Start(Path.Combine(assemblyPath, "nuget.exe"), string.Join(" ", args))?.WaitForExit();
return packageInfo.Id;
}
}
}