Skip to content

Commit 01bb4be

Browse files
committed
Adds FAQ
1 parent 5f81d34 commit 01bb4be

File tree

4 files changed

+209
-1
lines changed

4 files changed

+209
-1
lines changed

docs/en/FAQ/faq.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
??? question "Why FlubuCore?"
2+
- Native access to the whole .NET ecosystem and full IDE support inside of your scripts.
3+
- With flubu you can execute your script anywhere it doesn't need to be in a project.
4+
This is important for deployment scripts or if you want to write some other scripts that are not releated to build scirpts or deploy scripts
5+
- Flubu allows multiple tasks in target.
6+
- Easy access to tasks through fluent interface `Context.AddTask()` or `Context.Tasks()`
7+
- Each Flubu built in task derives from base class task meaning each built in task have retry, OnError, Finally, When, Interactive and some others mechanisms
8+
- Pass command line arguments, settings from json configuration file or environment variables to your Properties in script.
9+
- Allows you to reuse set of tasks. See [Sample](https://github.com/dotnetcore/FlubuCore.Examples/blob/master/DeployScriptExample/BuildScript/DeployScript.cs)
10+
- flubu supports parallel / async execution of target's, target dependencies and tasks
11+
- to each task that execute external program or command you can add custom arguments with .WithArguments() method or even decide not to use fluent interface (good example: https://github.com/azabluda/InfoCarrier.Core/blob/develop/BuildScript/BuildScript.cs)
12+
- Alternative target definitions with attributes
13+
- Flubu web api allows you to execute scripts remotely (usefull for deployments but not limited to)
14+
- Override existing options or add additional options to tasks through console. https://flubucore.dotnetcore.xyz/override-add-options/
15+
- Flubu have really nice interactive mode https://flubucore.dotnetcore.xyz/build-script-runner-interactive/
16+
- Flubu Supports .net 461+ and .net core 1.0
17+
??? question "Should I call Execute method when executing flubu built in task?"
18+
if you are adding task to target through `AddTask` method Flubu calls `Execute` method when executing that target so in this scenario you should not call `Execute` on the task
19+
```c#
20+
context.CreateTarget("Build")
21+
.AddCoreTask(x => x.build());
22+
```
23+
24+
In the sample above `BuildTask` is added to the target. When target is executed Flubu executes all tasks that were added to target by calling task `Execute` method. in this case it executes `BuildTask`
25+
26+
```c#
27+
context.CreateTarget("LoginEcr")
28+
.Do(c =>
29+
{
30+
c.Tasks()
31+
.RunProgram("aws")
32+
.WithArguments("ecr", "get-login", "--region", "eu-central-1", "--no-include-email"))
33+
.Execute(context);
34+
}
35+
```
36+
37+
In this sample `Do` actually adds [DoTask](https://github.com/dotnetcore/FlubuCore/blob/master/src/FlubuCore/Tasks/DoTask.cs) to the target. When target is executed Flubu executes `DoTask`. DoTask in above example invokes Anonymous method which was assigned to the Action delegate (first parameter in Do Method).
38+
Flubu can not execute by itself tasks in the anonymous method you have to call `Execute()` method manually.
39+
40+
??? question "Can I get output of the program, process or command that I am executing with Flubu?"
41+
Yes you can with `CaptureOutput` method in `RunProgramTask`
42+
43+
```c#
44+
public class MyScript : DefaultBuildScript
45+
{
46+
protected override void ConfigureTargets(ITaskContext context)
47+
{
48+
context.CreateTarget("Example")
49+
.Do(RunProgramOrCommandExample);
50+
}
51+
52+
public void RunProgramOrCommandExample(ITaskContext context)
53+
{
54+
var task = context.Tasks().RunProgramTask("EnterPathToProgramOrCommand")
55+
.WithArguments("Add arguments if needed")
56+
.CaptureOutput();
57+
58+
task.Execute(context);
59+
60+
var output = task.GetOutput();
61+
}
62+
}
63+
```
64+
65+
??? question "Can I access Properties or flubu BuildProperties in ConfigureTargets method?"
66+
In most cases you can as long as they are not set in a `Do` method or in a task.
67+
68+
69+
```c#
70+
public BuildVersion BuildVersion { get; set; } = null;
71+
72+
public int SimpleSample {get; set; } = 0;
73+
74+
protected override void ConfigureTargets(ITaskContext context)
75+
{
76+
var fetchBuildVersion context.CreateTarget("fetch.buildVersion").Do(FetchBuildVersion);
77+
78+
context.CreateTarget("Build")
79+
.DependsOn(fetchBuildVersion)
80+
.AddCoreTask(x => x.Build()
81+
.Version(BuildVersion.BuildVersionWithQuality())); /// BuildVersion is null here.
82+
83+
context.LogInfo($"sample value: '{SimpleSample}'"); /// logs 0 and not 5. Explained below why is it so.
84+
}
85+
86+
private void FetchBuildVersion(ITaskContext context)
87+
{
88+
BuildVersion = context.Tasks().FetchBuildVersionFromFileTask()
89+
.ProjectVersionFileName("project_version.txt")
90+
.Execute(context);
91+
92+
SimpleSample = 5;
93+
}
94+
```
95+
96+
In sample above you could think that when property `SimpleSample` is accessed in
97+
`ConfigureTargets` it would not be 0 but it is becuase `ConfigureTargets` method
98+
is always executed before all targets that are executed with flubu
99+
100+
!!! note "ConfigureTargets is also executed before all target dependecnies and tasks that were added to target"
101+
102+

docs/zh/FAQ/faq.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
??? question "Why FlubuCore?"
2+
- Native access to the whole .NET ecosystem and full IDE support inside of your scripts.
3+
- With flubu you can execute your script anywhere it doesn't need to be in a project.
4+
This is important for deployment scripts or if you want to write some other scripts that are not releated to build scirpts or deploy scripts
5+
- Flubu allows multiple tasks in target.
6+
- Easy access to tasks through fluent interface `Context.AddTask()` or `Context.Tasks()`
7+
- Each Flubu built in task derives from base class task meaning each built in task have retry, OnError, Finally, When, Interactive and some others mechanisms
8+
- Pass command line arguments, settings from json configuration file or environment variables to your Properties in script.
9+
- Allows you to reuse set of tasks. See [Sample](https://github.com/dotnetcore/FlubuCore.Examples/blob/master/DeployScriptExample/BuildScript/DeployScript.cs)
10+
- flubu supports parallel / async execution of target's, target dependencies and tasks
11+
- to each task that execute external program or command you can add custom arguments with .WithArguments() method or even decide not to use fluent interface (good example: https://github.com/azabluda/InfoCarrier.Core/blob/develop/BuildScript/BuildScript.cs)
12+
- Alternative target definitions with attributes
13+
- Flubu web api allows you to execute scripts remotely (usefull for deployments but not limited to)
14+
- Override existing options or add additional options to tasks through console. https://flubucore.dotnetcore.xyz/override-add-options/
15+
- Flubu have really nice interactive mode https://flubucore.dotnetcore.xyz/build-script-runner-interactive/
16+
- Flubu Supports .net 461+ and .net core 1.0
17+
??? question "Should I call Execute method when executing flubu built in task?"
18+
if you are adding task to target through `AddTask` method Flubu calls `Execute` method when executing that target so in this scenario you should not call `Execute` on the task
19+
```c#
20+
context.CreateTarget("Build")
21+
.AddCoreTask(x => x.build());
22+
```
23+
24+
In the sample above `BuildTask` is added to the target. When target is executed Flubu executes all tasks that were added to target by calling task `Execute` method. in this case it executes `BuildTask`
25+
26+
```c#
27+
context.CreateTarget("LoginEcr")
28+
.Do(c =>
29+
{
30+
c.Tasks()
31+
.RunProgram("aws")
32+
.WithArguments("ecr", "get-login", "--region", "eu-central-1", "--no-include-email"))
33+
.Execute(context);
34+
}
35+
```
36+
37+
In this sample `Do` actually adds [DoTask](https://github.com/dotnetcore/FlubuCore/blob/master/src/FlubuCore/Tasks/DoTask.cs) to the target. When target is executed Flubu executes `DoTask`. DoTask in above example invokes Anonymous method which was assigned to the Action delegate (first parameter in Do Method).
38+
Flubu can not execute by itself tasks in the anonymous method you have to call `Execute()` method manually.
39+
40+
??? question "Can I get output of the program, process or command that I am executing with Flubu?"
41+
Yes you can with `CaptureOutput` method in `RunProgramTask`
42+
43+
```c#
44+
public class MyScript : DefaultBuildScript
45+
{
46+
protected override void ConfigureTargets(ITaskContext context)
47+
{
48+
context.CreateTarget("Example")
49+
.Do(RunProgramOrCommandExample);
50+
}
51+
52+
public void RunProgramOrCommandExample(ITaskContext context)
53+
{
54+
var task = context.Tasks().RunProgramTask("EnterPathToProgramOrCommand")
55+
.WithArguments("Add arguments if needed")
56+
.CaptureOutput();
57+
58+
task.Execute(context);
59+
60+
var output = task.GetOutput();
61+
}
62+
}
63+
```
64+
65+
??? question "Can I access Properties or flubu BuildProperties in ConfigureTargets method?"
66+
In most cases you can as long as they are not set in a `Do` method or in a task.
67+
68+
69+
```c#
70+
public BuildVersion BuildVersion { get; set; } = null;
71+
72+
public int SimpleSample {get; set; } = 0;
73+
74+
protected override void ConfigureTargets(ITaskContext context)
75+
{
76+
var fetchBuildVersion context.CreateTarget("fetch.buildVersion").Do(FetchBuildVersion);
77+
78+
context.CreateTarget("Build")
79+
.DependsOn(fetchBuildVersion)
80+
.AddCoreTask(x => x.Build()
81+
.Version(BuildVersion.BuildVersionWithQuality())); /// BuildVersion is null here.
82+
83+
context.LogInfo($"sample value: '{SimpleSample}'"); /// logs 0 and not 5. Explained below why is it so.
84+
}
85+
86+
private void FetchBuildVersion(ITaskContext context)
87+
{
88+
BuildVersion = context.Tasks().FetchBuildVersionFromFileTask()
89+
.ProjectVersionFileName("project_version.txt")
90+
.Execute(context);
91+
92+
SimpleSample = 5;
93+
}
94+
```
95+
96+
In sample above you could think that when property `SimpleSample` is accessed in
97+
`ConfigureTargets` it would not be 0 but it is becuase `ConfigureTargets` method
98+
is always executed before all targets that are executed with flubu
99+
100+
!!! note "ConfigureTargets is also executed before all target dependecnies and tasks that were added to target"
101+
102+

mkdocs-zh.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ nav:
4343
- '入门' : 'WebApi/getting-started.md'
4444
- '插件精选':
4545
- '插件': 'AwesomePlugins/awesome-plugins.md'
46+
- 'FAQ':
47+
- 'FlubuCore': 'FAQ/faq.md'
4648
- '示例' :
4749
- 'Index' : 'https://github.com/dotnetcore/FlubuCore.Examples'
4850

mkdocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ nav:
3838
- 'Awesome plugins':
3939
- 'Plugins': 'AwesomePlugins/awesome-plugins.md'
4040
- 'Examples' :
41-
- 'Index' : 'https://github.com/dotnetcore/FlubuCore.Examples'
41+
- 'Index' : 'https://github.com/dotnetcore/FlubuCore.Examples'
42+
- 'FAQ':
43+
- 'FlubuCore': 'FAQ/faq.md'
4244
- 'Blogs':
4345
- 'Blogs': 'Blogs/blogs.md'
4446
- '中文' :

0 commit comments

Comments
 (0)