Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension/src/debugger/languages/dotnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export function createProjectDebuggerExtension(dotNetServiceProducer: (debugSess
// The apphost's application URL is the Aspire dashboard URL. We already get the dashboard login URL later on,
// so we should just avoid setting up serverReadyAction and manually open the browser ourselves.
if (!launchOptions.isApphost) {
debugConfiguration.serverReadyAction = determineServerReadyAction(baseProfile?.launchBrowser, baseProfile?.applicationUrl);
debugConfiguration.serverReadyAction = determineServerReadyAction(baseProfile?.launchBrowser, baseProfile?.applicationUrl, baseProfile?.launchUrl);
}

// Temporarily disable GH Copilot on the dashboard before the extension implementation is approved
Expand Down
9 changes: 8 additions & 1 deletion extension/src/debugger/launchProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export interface LaunchProfile {
environmentVariables?: { [key: string]: string };
// checkForDevCert in debug configuration
useSSL?: boolean;
// The relative URL to launch in the browser.
Comment thread
neoGeneva marked this conversation as resolved.
Outdated
Comment thread
adamint marked this conversation as resolved.
Outdated
launchUrl?: string;
}

/**
Expand Down Expand Up @@ -254,13 +256,18 @@ interface ServerReadyAction {
uriFormat: string;
}

export function determineServerReadyAction(launchBrowser?: boolean, applicationUrl?: string): ServerReadyAction | undefined {
export function determineServerReadyAction(launchBrowser?: boolean, applicationUrl?: string, launchUrl?: string): ServerReadyAction | undefined {
if (!launchBrowser || !applicationUrl) {
return undefined;
}

let uriFormat = applicationUrl.includes(';') ? applicationUrl.split(';')[0] : applicationUrl;

if (launchUrl) {
Comment thread
adamint marked this conversation as resolved.
// Ensure launchUrl is an absolute URL by resolving it against the applicationUrl
uriFormat = new URL(launchUrl, uriFormat).href;
Comment thread
adamint marked this conversation as resolved.
Outdated
}

return {
action: "openExternally",
pattern: "\\bNow listening on:\\s+https?://\\S+",
Expand Down
34 changes: 29 additions & 5 deletions extension/src/test/launchProfiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,18 +515,18 @@ suite('Launch Profile Tests', () => {

suite('determineServerReadyAction', () => {
test('returns undefined when launchBrowser is false', () => {
const result = determineServerReadyAction(false, 'https://localhost:5001');
const result = determineServerReadyAction(false, 'https://localhost:5001', undefined);
assert.strictEqual(result, undefined);
});

test('returns undefined when applicationUrl is undefined', () => {
const result = determineServerReadyAction(true, undefined);
const result = determineServerReadyAction(true, undefined, undefined);
assert.strictEqual(result, undefined);
});

test('returns serverReadyAction when launchBrowser true and applicationUrl provided', () => {
const applicationUrl = 'https://localhost:5001';
const result = determineServerReadyAction(true, applicationUrl);
const result = determineServerReadyAction(true, applicationUrl, undefined);

assert.notStrictEqual(result, undefined);
assert.strictEqual(result?.action, 'openExternally');
Expand All @@ -536,13 +536,35 @@ suite('Launch Profile Tests', () => {

test('returns serverReadyAction with first URL when multiple URLs separated by semicolon', () => {
const applicationUrl = 'https://localhost:5001;http://localhost:5000';
const result = determineServerReadyAction(true, applicationUrl);
const result = determineServerReadyAction(true, applicationUrl, undefined);

assert.notStrictEqual(result, undefined);
assert.strictEqual(result?.action, 'openExternally');
assert.strictEqual(result?.uriFormat, 'https://localhost:5001');
assert.strictEqual(result?.pattern, '\\bNow listening on:\\s+https?://\\S+');
});

test('returns serverReadyAction with absolute launchUrl', () => {
Comment thread
adamint marked this conversation as resolved.
const applicationUrl = 'https://localhost:5001;http://localhost:5000';
const launchUrl = 'https://localhost:5001/some/path';
const result = determineServerReadyAction(true, applicationUrl, launchUrl);

assert.notStrictEqual(result, undefined);
assert.strictEqual(result?.action, 'openExternally');
assert.strictEqual(result?.uriFormat, 'https://localhost:5001/some/path');
assert.strictEqual(result?.pattern, '\\bNow listening on:\\s+https?://\\S+');
});

test('returns serverReadyAction with relative launchUrl', () => {
const applicationUrl = 'https://localhost:5001;http://localhost:5000';
const launchUrl = '/some/path';
const result = determineServerReadyAction(true, applicationUrl, launchUrl);

assert.notStrictEqual(result, undefined);
assert.strictEqual(result?.action, 'openExternally');
assert.strictEqual(result?.uriFormat, 'https://localhost:5001/some/path');
assert.strictEqual(result?.pattern, '\\bNow listening on:\\s+https?://\\S+');
});
});

suite('readLaunchSettings', () => {
Expand Down Expand Up @@ -632,7 +654,8 @@ suite('Launch Profile Tests', () => {
},
// Comment before applicationUrl
"applicationUrl": "https://localhost:5001",
"launchBrowser": true
"launchBrowser": true,
"launchUrl": "https://localhost:5001/launch"
},
// Another profile
"Production": {
Expand All @@ -654,6 +677,7 @@ suite('Launch Profile Tests', () => {
assert.strictEqual(result!.profiles['Development'].environmentVariables!.LOG_LEVEL, 'Debug');
assert.strictEqual(result!.profiles['Development'].applicationUrl, 'https://localhost:5001');
assert.strictEqual(result!.profiles['Development'].launchBrowser, true);
assert.strictEqual(result!.profiles['Development'].launchUrl, 'https://localhost:5001/launch');
Comment thread
neoGeneva marked this conversation as resolved.
assert.strictEqual(result!.profiles['Production'].environmentVariables!.ASPNETCORE_ENVIRONMENT, 'Production');
});

Expand Down
Loading