-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.csx
102 lines (87 loc) · 2.89 KB
/
build.csx
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System.Diagnostics;
var Configuration = System.Environment.GetEnvironmentVariable("Configuration");
var Targets = System.Environment.GetEnvironmentVariable("Targets");
var MsBuildExe = System.Environment.GetEnvironmentVariable("MsBuildExe");
var NuGet = System.Environment.GetEnvironmentVariable("NuGet");
var testFramework = "net46";
if (string.IsNullOrEmpty(Configuration)) Configuration = "Release";
if (string.IsNullOrEmpty(Targets)) Targets = "Restore,Rebuild";
if (string.IsNullOrEmpty(MsBuildExe)) MsBuildExe = Path.Combine(System.Environment.GetEnvironmentVariable("ProgramFiles(x86)"), @"Microsoft Visual Studio\Preview\Community\MSBuild\15.0\Bin\MSBuild.exe");
if (string.IsNullOrEmpty(NuGet)) NuGet = @"c:\nuget\nuget.exe";
Action<string> hdr = (msg) =>
{
Console.WriteLine($"------------------------------");
Console.WriteLine($" {msg}");
Console.WriteLine($"------------------------------");
};
Action<bool, string, string> run = (shell, file, args) =>
{
ProcessStartInfo psi = null;
if (shell)
{
psi = new ProcessStartInfo()
{
FileName = $"cmd",
Arguments = $"/c {file} {args}",
UseShellExecute = false
};
}
else
{
psi = new ProcessStartInfo()
{
FileName = file,
Arguments = args,
UseShellExecute = false
};
}
var p = Process.Start(psi);
p.WaitForExit();
if (p.ExitCode != 0) System.Environment.Exit(p.ExitCode);
};
//-------------------------------BUILD
{
hdr("BUILD");
//
// msbuild targets
//
foreach (var prj in new[] { "src/SearchAThing.Sci.csproj", "tests/SearchAThing.Sci.Tests.csproj" })
{
run(false, MsBuildExe, $"{prj} " +
$"/t:{Targets} " +
$"/p:Configuration={Configuration} /p:NoWarn=\"1591,1573\" " +
$"/m /v:M /fl /flp:LogFile=msbuild.log;Verbosity=Normal /nr:false");
}
}
//-------------------------------UNIT TEST
{
hdr("UNIT TEST");
//
// install xunit.runner.console
//
run(false, NuGet, "install xunit.runner.console -Version 2.2.0 -OutputDirectory packages");
//
// install opencover
//
run(false, NuGet, "install OpenCover -Version 4.6.519 -OutputDirectory packages");
//
// run codecover
//
run(false, @"packages\OpenCover.4.6.519\tools\OpenCover.Console.exe",
@"-register:user -target:""packages\xunit.runner.console.2.2.0\tools\xunit.console.exe"" " +
$@"-targetargs:"".\tests\bin\Release\{testFramework}\SearchAThing.Sci.Tests.dll -noshadow"" " +
@"-output:"".\coverage.xml"" " +
"\"-filter:+[*]* -[*]Microsoft.Xna.*\"");
}
//-------------------------------COVERAGE
{
hdr("COVERAGE");
//
// ensure codecov
//
run(true, "npm", "install codecov -g");
//
// run codecov
//
run(true, "codecov", "-f coverage.xml");
}