You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .claude/skills/aspire-restart/SKILL.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ description: Start or restart the .NET Aspire AppHost via the developer CLI. Alw
6
6
# Restart Aspire
7
7
8
8
```bash
9
-
dotnet run --project developer-cli -- restart [<basePort>]
9
+
dotnet run --project developer-cli -- restart
10
10
```
11
11
12
12
Use `developer-cli` exactly as written - do not expand to an absolute worktree path.
@@ -15,7 +15,6 @@ Stops any running Aspire AppHost and starts a fresh instance. Detached by defaul
15
15
16
16
Always use `restart`, even when nothing is running yet. It is a no-op when Aspire is not up, and the safe default in every other case. Never use the developer CLI's `run` command, `aspire run`, or `aspire restart`.
17
17
18
-
-`<basePort>` - optional positional argument; written to `.workspace/port.txt` before Aspire starts
19
18
-`--public-url <url>` - set `PUBLIC_URL` (e.g. an ngrok URL)
20
19
21
20
## When to use
@@ -25,10 +24,9 @@ Always use `restart`, even when nothing is running yet. It is a no-op when Aspir
25
24
- When hot reload breaks or stops picking up changes.
26
25
- Before running e2e tests on a fresh stack.
27
26
28
-
## Picking the base port
27
+
## Port allocation
29
28
30
-
- In the git root: omit `<basePort>` (uses the default).
31
-
- In a worktree: on the first start, pick the first free port from `10000`, `11000`, `12000`, `13000` (`lsof -i :<port>` on macOS/Linux, `netstat -ano | findstr :<port>` on Windows). Keep using that port for the lifetime of the worktree - never change it after.
29
+
Fully automatic. On a fresh checkout the developer CLI bootstraps `.workspace/port.txt`: the root gets the default base port; worktrees scan a fixed list of candidates and pick the first one whose ports are all free. Once written, the file is the authoritative allocation for the lifetime of the checkout.
Copy file name to clipboardExpand all lines: developer-cli/Commands/RestartCommand.cs
+2-8Lines changed: 2 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -11,38 +11,32 @@ public class RestartCommand : Command
11
11
{
12
12
publicRestartCommand():base("restart","Stops any running Aspire AppHost and starts a fresh instance")
13
13
{
14
-
varbasePortArgument=newArgument<int?>("basePort"){Description="Optional base port. If provided, written to .workspace/port.txt before Aspire starts.",DefaultValueFactory= _ =>null};
15
14
varwatchOption=newOption<bool>("--watch","-w"){Description="Enable watch mode for hot reload"};
16
15
varattachOption=newOption<bool>("--attach","-a"){Description="Keep the CLI process attached to the Aspire process (detached is the default)"};
17
16
varpublicUrlOption=newOption<string?>("--public-url"){Description="Set the PUBLIC_URL environment variable for the app (e.g., https://example.ngrok-free.app)"};
Copy file name to clipboardExpand all lines: developer-cli/Commands/RunCommand.cs
+3-22Lines changed: 3 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -13,18 +13,15 @@ public class RunCommand : Command
13
13
{
14
14
publicRunCommand():base("run","Runs Aspire AppHost (use --watch for hot reload)")
15
15
{
16
-
varbasePortArgument=newArgument<int?>("basePort"){Description="Optional base port. If provided, written to .workspace/port.txt before Aspire starts.",DefaultValueFactory= _ =>null};
17
16
varwatchOption=newOption<bool>("--watch","-w"){Description="Enable watch mode for hot reload"};
18
17
varattachOption=newOption<bool>("--attach","-a"){Description="Keep the CLI process attached to the Aspire process (detached is the default)"};
19
18
varpublicUrlOption=newOption<string?>("--public-url"){Description="Set the PUBLIC_URL environment variable for the app (e.g., https://example.ngrok-free.app)"};
20
19
21
-
Arguments.Add(basePortArgument);
22
20
Options.Add(watchOption);
23
21
Options.Add(attachOption);
24
22
Options.Add(publicUrlOption);
25
23
26
24
SetAction(parseResult =>Execute(
27
-
parseResult.GetValue(basePortArgument),
28
25
parseResult.GetValue(watchOption),
29
26
parseResult.GetValue(attachOption),
30
27
parseResult.GetValue(publicUrlOption)
@@ -34,9 +31,6 @@ public class RunCommand : Command
34
31
35
32
// The CLI binary is published outside the repo, so PortAllocation.Load (which walks up from
36
33
// AppContext.BaseDirectory) cannot find the repo. Use the CLI's known SourceCodeFolder instead.
37
-
// Re-read on every access so a run/restart invocation with a positional base port picks up the
38
-
// freshly written .workspace/port.txt without any cached PortAllocation lingering from earlier
?$"Aspire AppHost is already running on port {AspirePort}. Run '{alias} stop' to stop it or '{alias} restart' to start a fresh instance."
59
-
:$"Aspire AppHost is already running on port {AspirePort}. Run '{alias} stop' first or use '{alias} restart {basePort}' to switch.";
60
-
AnsiConsole.MarkupLine($"[yellow]{message}[/]");
51
+
AnsiConsole.MarkupLine($"[yellow]Aspire AppHost is already running on port {AspirePort}. Run '{alias} stop' to stop it or '{alias} restart' to start a fresh instance.[/]");
0 commit comments