Skip to content

Commit 0a14ede

Browse files
committed
fix app.ConfigureServices invoked on every app.Run #218
1 parent ab313a9 commit 0a14ede

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

sandbox/GeneratorSandbox/Program.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,12 @@
22

33
var app = ConsoleApp.Create();
44

5-
app.Add("build|b", () => { });
6-
app.Add("keyvault|kv", () => { });
7-
app.Add<Commands>();
5+
app.ConfigureServices(_ => { Console.WriteLine("ConfigureServices"); });
6+
app.Add("test", () => Console.WriteLine("test output"));
87

9-
app.Run(args);
10-
11-
public class Commands
8+
for (var i = 0; i < 3; i++)
129
{
13-
/// <summary>
14-
/// Executes the check command using the specified coordinates.
15-
/// </summary>
16-
[Command("check|c")]
17-
public void Check() { }
18-
19-
/// <summary>Build this packages's and its dependencies' documenation.</summary>
20-
[Command("doc|d")]
21-
public void Doc() { }
10+
app.Run(["test"], startHost: false, stopHost: false, disposeServiceProvider: false);
2211
}
12+
13+

src/ConsoleAppFramework/CommandHelpBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static string BuildCommandHelpMessage(Command command)
4949

5050
public static string BuildCliSchema(IEnumerable<Command> commands)
5151
{
52-
return "return new[] {\n"
52+
return "return new CommandHelpDefinition[] {\n"
5353
+ string.Join(", \n", commands.Select(x => CreateCommandHelpDefinition(x).ToCliSchema()))
5454
+ "\n};";
5555
}

src/ConsoleAppFramework/Emitter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,7 @@ public void EmitConfigure(SourceBuilder sb, DllReference dllReference)
960960
{
961961
sb.AppendLine("return;");
962962
}
963+
sb.AppendLine("isRequireCallBuildAndSetServiceProvider = false;");
963964

964965
if (dllReference.HasConfiguration)
965966
{

0 commit comments

Comments
 (0)