Skip to content

Commit 7ed6308

Browse files
committed
Adds OnBuildInitialized, BeforeEachTargetExecution, AfterEachTargetExecution
1 parent 2ce0d47 commit 7ed6308

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
## FlubuCore 6.3.1.0
2+
- Fixes BeforeBuildExecution event.
3+
14
## FlubuCore 6.3.0.0
5+
- Adds OnBuildInitialzed, BeforeEachTargetExecuion and AfterEachTargetExecution events.
26
- Dependencies can now be added to group of tasks in target.
37
- Added ExecuteOnlyWhen to group of tasks in target. Tasks in group are only executed when condition is meet.
48
- Fixed directory and file suggestions in flubu interactive mode.

src/Build.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,9 @@
147147
<PackageReference Include="FlubuCore" Version="5.1.8" />
148148
<PackageReference Include="LiteDB" Version="5.0.11" />
149149
</ItemGroup>
150+
<ItemGroup>
151+
<Content Include="..\CHANGELOG.md">
152+
<Link>CHANGELOG.md</Link>
153+
</Content>
154+
</ItemGroup>
150155
</Project>

src/FlubuCore/Scripting/DefaultBuildScript.cs

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public int Run(IFlubuSession flubuSession)
5151

5252
try
5353
{
54+
BeforeBuildExecution(flubuSession);
5455
RunBuild(flubuSession);
5556
flubuSession.Complete();
5657
AfterBuildExecution(flubuSession);
@@ -137,7 +138,6 @@ public static (List<string> targetsToRun, bool unknownTarget, List<string> notFo
137138

138139
private void RunBuild(IFlubuSession flubuSession)
139140
{
140-
BeforeBuildExecution(flubuSession);
141141
flubuSession.TargetTree.ResetTargetTree();
142142
ConfigureDefaultProps(flubuSession);
143143
ConfigureBuildProperties(flubuSession);
@@ -149,7 +149,7 @@ private void RunBuild(IFlubuSession flubuSession)
149149
_targetCreator.CreateTargetFromMethodAttributes(this, flubuSession);
150150

151151
ConfigureTargets(flubuSession);
152-
152+
OnBuildInitialized(flubuSession);
153153
if (!flubuSession.Args.InteractiveMode)
154154
{
155155
var targetsInfo = ParseCmdLineArgs(flubuSession.Args.MainCommands, flubuSession.TargetTree);
@@ -215,7 +215,9 @@ private void ExecuteTarget(IFlubuSession flubuSession, (List<string> targetsToRu
215215
BeforeTargetExecution(flubuSession);
216216
foreach (var targetToRun in targetsInfo.targetsToRun)
217217
{
218+
BeforeEachTargetExecution(flubuSession);
218219
flubuSession.TargetTree.RunTarget(flubuSession, targetToRun);
220+
AfterEachTargetExecution(flubuSession);
219221
}
220222

221223
AfterTargetExecution(flubuSession);
@@ -250,18 +252,58 @@ private void ExecuteTarget(IFlubuSession flubuSession, (List<string> targetsToRu
250252
AssertAllTargetDependenciesWereExecuted(flubuSession);
251253
}
252254

255+
/// <summary>
256+
/// Event that happens before all targets get executed.
257+
/// </summary>
258+
/// <param name="context"></param>
253259
protected virtual void BeforeTargetExecution(ITaskContext context)
254260
{
255261
}
256262

263+
/// <summary>
264+
/// Event that happens after all targets get executed.
265+
/// </summary>
266+
/// <param name="context"></param>
257267
protected virtual void AfterTargetExecution(ITaskContext context)
258268
{
259269
}
260270

271+
/// <summary>
272+
/// Event that happens before each target get executed.
273+
/// </summary>
274+
/// <param name="context"></param>
275+
protected virtual void BeforeEachTargetExecution(ITaskContext context)
276+
{
277+
}
278+
279+
/// <summary>
280+
/// Event that happens after each target get executed.
281+
/// </summary>
282+
/// <param name="context"></param>
283+
protected virtual void AfterEachTargetExecution(ITaskContext context)
284+
{
285+
}
286+
287+
/// <summary>
288+
/// Event that happens before build is executed. Target's and properties are not yet configured.
289+
/// </summary>
290+
/// <param name="context"></param>
261291
protected virtual void BeforeBuildExecution(ITaskContext context)
262292
{
263293
}
264294

295+
/// <summary>
296+
/// Event that happens when build is initialized. Target's and properties are configured.
297+
/// </summary>
298+
/// <param name="context"></param>
299+
protected virtual void OnBuildInitialized(ITaskContext context)
300+
{
301+
}
302+
303+
/// <summary>
304+
/// Event that happens when build is finished.
305+
/// </summary>
306+
/// <param name="context"></param>
265307
protected virtual void AfterBuildExecution(IFlubuSession session)
266308
{
267309
if (session.Args.GenerateContinousIntegrationConfigs != null &&
@@ -273,6 +315,11 @@ protected virtual void AfterBuildExecution(IFlubuSession session)
273315
session.TargetTree.LogBuildSummary(session);
274316
}
275317

318+
/// <summary>
319+
/// Event that happends when build has failed.
320+
/// </summary>
321+
/// <param name="session"></param>
322+
/// <param name="ex"></param>
276323
protected virtual void OnBuildFailed(IFlubuSession session, Exception ex)
277324
{
278325
}

0 commit comments

Comments
 (0)