-
Notifications
You must be signed in to change notification settings - Fork 64
/
Nake.csx
56 lines (44 loc) · 1.75 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
#r "System.Xml"
#r "System.Xml.Linq"
using System.Linq;
using System.Net;
using System.Xml.Linq;
using System.Diagnostics;
using System.Text.RegularExpressions;
using static Nake.App;
using static Nake.Env;
using static Nake.FS;
using static Nake.Log;
using static Nake.Run;
const string Project = "Streamstone";
const string RootPath = "%NakeScriptDirectory%";
const string OutputPath = RootPath + @"\Output";
var AppVeyor = Var["APPVEYOR"] == "True";
/// Builds sources in Debug mode
[Task] void Default() => Build();
/// Builds sources using specified configuration and output path
[Step] void Build(string config = "Debug") =>
Exec("dotnet", "build {Project}.sln /p:Configuration={config}");
/// Runs unit tests
[Step] void Test()
{
Exec("dotnet", "test Source/Streamstone.Tests/Streamstone.Tests.csproj --configuration Debug -l:trx;LogFileName=nunit-test-results.trx --results-directory \"{OutputPath}\"");
var results = @"{OutputPath}\nunit-test-results.trx";
if (AppVeyor)
new WebClient().UploadFile("https://ci.appveyor.com/api/testresults/mstest/%APPVEYOR_JOB_ID%", results);
}
/// Builds official NuGet package
[Step] void Package()
{
Test();
Exec("dotnet", @"pack Source/Streamstone/Streamstone.csproj /p:PackageVersion={Version()} --configuration Release --output ""{OutputPath}""");
}
/// Publishes package to NuGet gallery
[Step] void Publish() => Cmd(@"Tools\Nuget.exe push {OutputPath}\{Project}.{Version()}.nupkg %NuGetApiKey% -Source https://nuget.org/");
string Version()
{
var version = File
.ReadAllLines(@"{RootPath}\Source\Streamstone.Version.cs")
.First(x => x.StartsWith("[assembly: AssemblyVersion("));
return new Regex(@"AssemblyVersion\(\""([^\""]*)\""\)").Match(version).Groups[1].Value;
}