forked from dotless/dotless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
111 lines (88 loc) · 3.51 KB
/
build.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
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
103
104
105
106
107
108
109
110
111
#tool nuget:?package=NUnit.ConsoleRunner
#tool nuget:?package=vswhere
#addin "nuget:?package=Cake.FileHelpers&version=3.1.0"
// ARGUMENTS
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var version = Argument("BuildVersion", "0.0.1");
// PREPARATION
// Define directories.
var outputDir = Directory("./BuildArtifacts");
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(outputDir);
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore("./dotless.sln");
});
Task("SetVersion")
.IsDependentOn("Clean")
.Does(() =>
{
ReplaceRegexInFiles("./src/dotless.AspNet/Properties/AssemblyInfo.cs", "(?<=AssemblyVersion\\(\")(.+?)(?=\"\\))", version);
ReplaceRegexInFiles("./src/dotless.AspNet/Properties/AssemblyInfo.cs", "(?<=AssemblyFileVersion\\(\")(.+?)(?=\"\\))", version);
ReplaceRegexInFiles("./src/dotless.Compiler/dotless.Compiler.csproj", "<Version>0.0.0.1</Version>", $"<Version>{version}</Version>");
ReplaceRegexInFiles("./src/dotless.Core/dotless.Core.csproj", "<Version>0.0.0.1</Version>", $"<Version>{version}</Version>");
});
Task("Build")
.IsDependentOn("Restore")
.IsDependentOn("SetVersion")
.Does(() =>
{
// get MSBuild 15 location
var vsLatest = VSWhereLatest(new VSWhereLatestSettings { Requires = "Microsoft.Component.MSBuild" });
FilePath msBuildPath = (vsLatest==null)
? null
: GetFiles(System.IO.Path.Combine(vsLatest.ToString(), "MSBuild/*/Bin/MSBuild.exe")).Single();
Information("Using MSBuild "+ msBuildPath);
MSBuild("./dotless.sln", new MSBuildSettings {
Verbosity = Verbosity.Minimal,
ToolPath = msBuildPath,
Configuration = configuration,
PlatformTarget = PlatformTarget.MSIL // AnyCPU
});
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
// run tests for .NET core projects
DotNetCoreTest("./tests/dotless.Core.Test/dotless.Core.Test.csproj");
// run other tests
NUnit3("./tests/dotless.AspNet.Test/bin/" + configuration + "/*.Test.dll",
new NUnit3Settings { NoResults = true }
);
NUnit3("./tests/dotless.CompatibilityTests/bin/" + configuration + "/*.Test.dll",
new NUnit3Settings { NoResults = true }
);
});
Task("Publish")
.IsDependentOn("Test")
.Does(() =>
{
var nuGetPackSettings = new NuGetPackSettings {
Version = version,
NoPackageAnalysis = false,
BasePath = "./src/dotless.Core/bin/"+configuration,
OutputDirectory = outputDir
};
NuGetPack("./nuspec/dotless.Core.nuspec", nuGetPackSettings);
nuGetPackSettings.BasePath = "./src/dotless.AspNet/bin/"+configuration;
NuGetPack("./nuspec/dotless.AspNetHandler.nuspec", nuGetPackSettings);
nuGetPackSettings.BasePath = "./";
NuGetPack("./nuspec/dotless.nuspec", nuGetPackSettings);
nuGetPackSettings.BasePath = "./src/dotless.Compiler/bin/"+configuration;
NuGetPack("./nuspec/dotless.CLI.nuspec", nuGetPackSettings);
});
// TASK TARGETS
Task("Default")
.IsDependentOn("Test");
// EXECUTION
RunTarget(target);