forked from pauldotknopf/dotnet-buildary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectDefinition.cs
69 lines (57 loc) · 2.24 KB
/
ProjectDefinition.cs
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
using static Build.Buildary.Log;
using static Build.Buildary.GitVersion;
using static Build.Buildary.Path;
using static Bullseye.Targets;
using static Build.Buildary.Directory;
using static Build.Buildary.Shell;
using static Build.Buildary.File;
namespace Build.Buildary
{
public class ProjectDefinition
{
public string SolutionPath { get; set; }
public static void Register(Runner.RunnerOptions options, ProjectDefinition definition)
{
Info($"Configuration: {options.Config}");
var gitVersion = GetGitVersion(ExpandPath("./"));
Info($"Version: {gitVersion.FullVersion}");
var commandBuildArgs = $"--configuration {options.Config}";
var commandBuildArgsWithVersion = commandBuildArgs;
if (!string.IsNullOrEmpty(gitVersion.PreReleaseTag))
{
commandBuildArgsWithVersion += $" --version-suffix \"{gitVersion.PreReleaseTag}\"";
}
Target("clean", () =>
{
CleanDirectory(ExpandPath("./output"));
});
Target("update-version", () =>
{
if (FileExists("./build/version.props"))
{
DeleteFile("./build/version.props");
}
WriteFile("./build/version.props",
$@"<Project>
<PropertyGroup>
<VersionPrefix>{gitVersion.Version}</VersionPrefix>
</PropertyGroup>
</Project>");
});
Target("build", () =>
{
RunShell($"dotnet build {commandBuildArgs} {ExpandPath(definition.SolutionPath)}");
});
Target("test", () =>
{
RunShell($"dotnet test {commandBuildArgs} {ExpandPath(definition.SolutionPath)}");
});
Target("deploy", () =>
{
RunShell($"dotnet pack --output {ExpandPath("./output")} {commandBuildArgsWithVersion} {ExpandPath(definition.SolutionPath)}");
});
Target("ci", DependsOn("clean", "update-version", "test", "deploy"));
Target("default", DependsOn("build"));
}
}
}