-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.cake
66 lines (53 loc) · 1.57 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
// ---------------- Includes ----------------
#load Chaskis/DevOps/MsBuildHelpers.cs
// ---------------- Constants ----------------
const string target = "run_devops";
const string buildTask = "build";
bool forceBuild = Argument<bool>( "force_build", false );
string targetArg = Argument( "target", string.Empty );
FilePath devopsExe = File( "./Chaskis/DevOps/bin/Debug/netcoreapp3.1/DevOps.dll" );
FilePath sln = File( "./Chaskis/Chaskis.sln" );
// ---------------- Targets ----------------
Task( buildTask )
.Does(
( context ) =>
{
if( forceBuild == false )
{
Information( "DevOps.dll not found, compiling" );
}
MsBuildHelpers.DoMsBuild( context, sln, "Debug" );
}
)
.Description( "Builds Chaskis with Debug turned on." );
var runTask = Task( target )
.Does(
() =>
{
List<string> args = new List<string>( System.Environment.GetCommandLineArgs() );
args.RemoveAt( 0 );
args.Insert( 0, devopsExe.ToString() );
ProcessSettings processSettings = new ProcessSettings
{
Arguments = ProcessArgumentBuilder.FromStrings( args )
};
int exitCode = StartProcess( "dotnet", processSettings );
if( exitCode != 0 )
{
throw new Exception( $"DevOps.exe Exited with exit code: {exitCode}" );
}
}
);
if( forceBuild || ( FileExists( devopsExe ) == false ) )
{
runTask.IsDependentOn( buildTask );
}
// ---------------- Run ----------------
if( targetArg == buildTask )
{
RunTarget( targetArg );
}
else
{
RunTarget( target );
}