Skip to content

Commit 411e352

Browse files
committed
Document AppHost launch path resolution
1 parent a95b110 commit 411e352

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

extension/src/test/aspireDebugConfigurationProvider.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ suite('AspireDebugConfigurationProvider', () => {
1717
fs.rmSync(tempDir, { recursive: true, force: true });
1818
});
1919

20-
test('resolves launch config C# AppHost source file to containing project file', async () => {
20+
test('resolves launch config SDK-style AppHost Program.cs to containing project file', async () => {
2121
const appHostDirectory = path.join(tempDir, 'AppHost');
2222
fs.mkdirSync(appHostDirectory);
2323

@@ -37,7 +37,7 @@ suite('AspireDebugConfigurationProvider', () => {
3737
assert.strictEqual(config?.program, projectPath);
3838
});
3939

40-
test('leaves launch config single-file C# AppHost source file unchanged', async () => {
40+
test('leaves launch config single-file apphost.cs unchanged', async () => {
4141
const appHostPath = path.join(tempDir, 'apphost.cs');
4242
fs.writeFileSync(appHostPath, '#:sdk Aspire.AppHost.Sdk\nvar builder = DistributedApplication.CreateBuilder(args);');
4343

extension/src/test/aspireEditorCommandProvider.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ suite('AspireEditorCommandProvider', () => {
5656
fs.rmSync(tempDir, { recursive: true, force: true });
5757
});
5858

59-
test('returns containing project file for active SDK-style C# AppHost source', async () => {
59+
test('returns containing project file when active editor is SDK-style AppHost Program.cs', async () => {
6060
const appHostDirectory = path.join(tempDir, 'AppHost');
6161
fs.mkdirSync(appHostDirectory);
6262

@@ -75,7 +75,7 @@ suite('AspireEditorCommandProvider', () => {
7575
}
7676
});
7777

78-
test('returns source file for active single-file C# AppHost', async () => {
78+
test('returns source file when active editor is single-file apphost.cs', async () => {
7979
const appHostPath = path.join(tempDir, 'apphost.cs');
8080
fs.writeFileSync(appHostPath, '#:sdk Aspire.AppHost.Sdk\nvar builder = DistributedApplication.CreateBuilder(args);');
8181
activeEditor = createEditor(appHostPath);

extension/src/utils/appHostLaunchPath.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export async function resolveAppHostLaunchPath(filePath: string): Promise<string
1717
}
1818

1919
const lines = fileText.split(/\r?\n/);
20+
21+
// Single-file C# AppHosts are launched directly from source and start with:
22+
// #:sdk Aspire.AppHost.Sdk
23+
// The CLI accepts this source file shape, so do not rewrite it to a project path.
2024
if (lines.some(line => line.startsWith('#:sdk Aspire.AppHost.Sdk'))) {
2125
return filePath;
2226
}
@@ -25,8 +29,10 @@ export async function resolveAppHostLaunchPath(filePath: string): Promise<string
2529
return filePath;
2630
}
2731

28-
// The CLI accepts a C# source file only for single-file AppHosts. SDK-style
29-
// C# AppHosts need their project file so the AppHost SDK and references load.
32+
// SDK-style C# AppHosts usually launch from Program.cs:
33+
// var builder = DistributedApplication.CreateBuilder(args);
34+
// The CLI needs the containing .csproj instead of Program.cs so the AppHost SDK
35+
// and project references load.
3036
return await tryFindContainingProjectFile(filePath) ?? filePath;
3137
}
3238

0 commit comments

Comments
 (0)