-
Notifications
You must be signed in to change notification settings - Fork 64
/
Nake.csx
75 lines (58 loc) · 2.34 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
#r "nuget: Nake.Meta, 3.0.0"
#r "nuget: Nake.Utility, 3.0.0"
#r "System.Net.WebClient"
using Nake;
using static Nake.FS;
using static Nake.Log;
using static Nake.Env;
using System.Linq;
using System.Net;
const string CoreProject = "Streamstone";
var RootPath = "%NakeScriptDirectory%";
var ArtifactsPath = $@"{RootPath}\Artifacts";
var ReleasePackagesPath = $@"{ArtifactsPath}\Release";
var AppVeyorJobId = Var["APPVEYOR_JOB_ID"];
var TargetFramework = "net8";
var Version = "3.0.0-dev";
/// Installs dependencies and builds sources in Debug mode
[Nake] async Task Default() => await Build();
/// Builds sources using specified configuration
[Step] async Task Build(string config = "Debug", bool verbose = false) =>
await $@"dotnet build {CoreProject}.sln /p:Configuration={config} {(verbose ? "/v:d" : "")}";
/// Runs unit tests
// Runs unit tests
[Nake] async Task Test(bool slow = false)
{
await Build("Debug");
var tests = new FileSet{$"{RootPath}/**/bin/Debug/{TargetFramework}/*.Tests.dll"}.ToString(" ");
var results = $@"{ArtifactsPath}/nunit-test-results.xml";
try
{
await $@"dotnet vstest {tests} --logger:trx;LogFileName={results} \
{(AppVeyorJobId != null||slow ? "" : "--TestCaseFilter:TestCategory!=Slow")}";
}
finally
{
if (AppVeyorJobId != null)
{
var workerApi = $"https://ci.appveyor.com/api/testresults/mstest/{AppVeyorJobId}";
Info($"Uploading {results} to {workerApi} using job id {AppVeyorJobId} ...");
var response = new WebClient().UploadFile(workerApi, results);
var result = Encoding.UTF8.GetString(response);
Info($"Appveyor response is: {result}");
}
}
}
/// Builds official NuGet packages
[Step] async Task Pack(bool skipFullCheck = false)
{
await Test(!skipFullCheck);
await Build("Release");
await $@"dotnet pack --no-build -c Release -p:IncludeSymbols=true \
-p:SymbolPackageFormat=snupkg -p:PackageVersion={Version} {CoreProject}.sln";
}
/// Publishes package to NuGet gallery
[Step] async Task Publish() => await Push(CoreProject);
async Task Push(string package) =>
await $@"dotnet nuget push {ReleasePackagesPath}\{package}.{Version}.nupkg \
-k %NuGetApiKey% -s https://nuget.org/ --skip-duplicate";