forked from OmniSharp/omnisharp-roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuget.cake
51 lines (40 loc) · 1.47 KB
/
nuget.cake
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
39
40
41
42
43
44
45
46
47
48
49
50
51
#load "runhelpers.cake"
private ExitStatus RunNuGetInstall(string packageIdOConfigFilePath, string version, bool excludeVersion, bool noCache, bool prerelease, string outputDirectory)
{
var nugetPath = Environment.GetEnvironmentVariable("NUGET_EXE");
var argList = new List<string> { "install", packageIdOConfigFilePath };
if (!string.IsNullOrWhiteSpace(version))
{
argList.Add("-Version");
argList.Add(version);
}
if (excludeVersion)
{
argList.Add("-ExcludeVersion");
}
if (noCache)
{
argList.Add("-NoCache");
}
if (prerelease)
{
argList.Add("-Prerelease");
}
if (!string.IsNullOrWhiteSpace(outputDirectory))
{
argList.Add("-OutputDirectory");
argList.Add(outputDirectory);
}
var arguments = string.Join(" ", argList);
return IsRunningOnWindows()
? Run(nugetPath, arguments)
: Run("mono", $"\"{nugetPath}\" {arguments}");
}
ExitStatus InstallNuGetPackage(string packageID, string version = null, bool excludeVersion = false, bool noCache = false, bool prerelease = false, string outputDirectory = null)
{
return RunNuGetInstall(packageID, version, excludeVersion, noCache, prerelease, outputDirectory);
}
ExitStatus InstallNuGetPackages(string configFilePath, bool excludeVersion = false, bool noCache = false, string outputDirectory = null)
{
return RunNuGetInstall(configFilePath, null, excludeVersion, noCache, false, outputDirectory);
}