-
Notifications
You must be signed in to change notification settings - Fork 64
/
Nake.csx
102 lines (81 loc) · 2.78 KB
/
Nake.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
#r "System.Xml"
#r "System.Xml.Linq"
using Nake.FS;
using Nake.Run;
using Nake.Log;
using Nake.Env;
using System.Linq;
using System.Net;
using System.Xml.Linq;
using System.Diagnostics;
const string Project = "Streamstone";
const string RootPath = "$NakeScriptDirectory$";
const string OutputPath = RootPath + @"\Output";
const string PackagePath = OutputPath + @"\Package";
const string ReleasePath = PackagePath + @"\Release";
var AppVeyor = Var["APPVEYOR"] == "True";
/// Builds sources in Debug mode
[Task] void Default()
{
Install();
Build();
}
/// Wipeout all build output and temporary build files
[Step] void Clean(string path = OutputPath)
{
Delete(@"{path}\*.*|-:*.vshost.exe");
RemoveDir(@"**\bin|**\obj|{path}\*|-:*.vshost.exe");
}
/// Builds sources using specified configuration and output path
[Step] void Build(string config = "Debug", string outDir = OutputPath)
{
Clean(outDir);
Exec(@"$ProgramFiles(x86)$\MSBuild\12.0\Bin\MSBuild.exe",
"{Project}.sln /p:Configuration={config};OutDir={outDir};ReferencePath={outDir}");
}
/// Runs unit tests
[Step] void Test(string outDir = OutputPath)
{
Build("Debug", outDir);
var tests = new FileSet{@"{outDir}\*.Tests.dll"}.ToString(" ");
var results = @"{outDir}\nunit-test-results.xml";
Cmd(@"Packages\NUnit.Runners.2.6.3\tools\nunit-console.exe " +
@"/xml:{results} /framework:net-4.0 /noshadow /nologo {tests}");
if (AppVeyor)
new WebClient().UploadFile("https://ci.appveyor.com/api/testresults/nunit/$APPVEYOR_JOB_ID$", results);
}
/// Builds official NuGet package
[Step] void Package()
{
Test(PackagePath + @"\Debug");
Build("Release", ReleasePath);
var version = FileVersionInfo
.GetVersionInfo(@"{ReleasePath}\{Project}.dll")
.FileVersion;
Cmd(@"Tools\Nuget.exe pack Build\{Project}.nuspec -Version {version} " +
"-OutputDirectory {PackagePath} -BasePath {RootPath} -NoPackageAnalysis");
}
/// Publishes package to NuGet gallery
[Step] void Publish()
{
Cmd(@"Tools\Nuget.exe push {PackagePath}\{Project}.{Version()}.nupkg $NuGetApiKey$");
}
string Version()
{
return FileVersionInfo
.GetVersionInfo(@"{ReleasePath}\{Project}.dll")
.FileVersion;
}
/// Installs dependencies (packages) from NuGet
[Task] void Install()
{
var packagesDir = @"{RootPath}\Packages";
var configs = XElement
.Load(packagesDir + @"\repositories.config")
.Descendants("repository")
.Select(x => x.Attribute("path").Value.Replace("..", RootPath));
foreach (var config in configs)
Cmd(@"Tools\NuGet.exe install {config} -o {packagesDir}");
// install packages required for building/testing/publishing package
Cmd(@"Tools\NuGet.exe install Build/Packages.config -o {packagesDir}");
}