Skip to content

Commit b5923b0

Browse files
RolandGuijtroland
andauthored
Add Aspire seed command + v8 migration (#323)
Co-authored-by: roland <roland.guijt@gmail.com>
1 parent b0afd93 commit b5923b0

5 files changed

Lines changed: 1776 additions & 1 deletion

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
var builder = DistributedApplication.CreateBuilder(args);
22
var idsvr = builder.AddProject<Projects.IdentityServerHost>("identityserverhost");
3+
4+
idsvr.WithCommand(
5+
name: "seed",
6+
displayName: "Seed Database",
7+
executeCommand: async (context) =>
8+
{
9+
var projectMetadata = idsvr.Resource.GetProjectMetadata();
10+
var projectPath = projectMetadata.ProjectPath;
11+
var process = new System.Diagnostics.Process
12+
{
13+
StartInfo = new System.Diagnostics.ProcessStartInfo
14+
{
15+
FileName = "dotnet",
16+
Arguments = $"run --project \"{projectPath}\" --no-build -- /seed",
17+
UseShellExecute = false,
18+
RedirectStandardOutput = true,
19+
RedirectStandardError = true,
20+
CreateNoWindow = true
21+
}
22+
};
23+
24+
process.Start();
25+
await process.WaitForExitAsync(context.CancellationToken);
26+
27+
if (process.ExitCode == 0)
28+
{
29+
return CommandResults.Success();
30+
}
31+
else
32+
{
33+
var error = await process.StandardError.ReadToEndAsync();
34+
return CommandResults.Failure(error);
35+
}
36+
},
37+
commandOptions: new CommandOptions
38+
{
39+
IconName = "DatabaseArrowUp",
40+
IsHighlighted = true
41+
});
42+
343
builder.AddProject<Projects.Client>("client")
444
.WaitFor(idsvr);
545
builder.Build().Run();

IdentityServer/v8/UserInteraction/DynamicProviders/IdentityServer.AppHost/AppHost.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,45 @@
22

33
var idsvr = builder.AddProject<Projects.IdentityServerHost>("identityserverhost");
44

5+
idsvr.WithCommand(
6+
name: "seed",
7+
displayName: "Seed Database",
8+
executeCommand: async (context) =>
9+
{
10+
var projectMetadata = idsvr.Resource.GetProjectMetadata();
11+
var projectPath = projectMetadata.ProjectPath;
12+
var process = new System.Diagnostics.Process
13+
{
14+
StartInfo = new System.Diagnostics.ProcessStartInfo
15+
{
16+
FileName = "dotnet",
17+
Arguments = $"run --project \"{projectPath}\" --no-build -- /seed",
18+
UseShellExecute = false,
19+
RedirectStandardOutput = true,
20+
RedirectStandardError = true,
21+
CreateNoWindow = true
22+
}
23+
};
24+
25+
process.Start();
26+
await process.WaitForExitAsync(context.CancellationToken);
27+
28+
if (process.ExitCode == 0)
29+
{
30+
return CommandResults.Success();
31+
}
32+
else
33+
{
34+
var error = await process.StandardError.ReadToEndAsync();
35+
return CommandResults.Failure(error);
36+
}
37+
},
38+
commandOptions: new CommandOptions
39+
{
40+
IconName = "DatabaseArrowUp",
41+
IsHighlighted = true
42+
});
43+
544
builder.AddProject<Projects.Client>("client")
645
.WaitFor(idsvr);
746

0 commit comments

Comments
 (0)