Skip to content

Support projectPath: '${file}' #8472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all 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
14 changes: 10 additions & 4 deletions src/shared/dotnetConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ class InternalServiceError extends Error {}
class UnavaliableLaunchServiceError extends Error {}

const workspaceFolderToken = '${workspaceFolder}';
const fileToken = '${file}';

/**
* Replaces '${workspaceFolder}' with the current folder while keeping path separators consistent.
* Replaces some '${variable}' tokens.
*
* @param projectPath The expected path to the .csproj
* @param folderPath The current workspace folder
* @returns A fully resolved path to the .csproj
*/
function resolveWorkspaceFolderToken(projectPath: string, folderPath: string): string {
function resolveVariableTokens(projectPath: string, folderPath: string): string {
if (projectPath === fileToken) {
return vscode.window.activeTextEditor?.document.fileName ?? projectPath;
}

if (projectPath.startsWith(workspaceFolderToken)) {
const relativeProjectPath: string = projectPath.substring(workspaceFolderToken.length);

// Keep the path seperate consistant
// Keep the path separators consistent
if (relativeProjectPath.startsWith('/')) {
folderPath = folderPath.replace(/[\\/]+/g, '/');
} else {
Expand Down Expand Up @@ -91,7 +97,7 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro
let projectPath: string | undefined = debugConfiguration.projectPath;
if (folder) {
if (projectPath) {
projectPath = resolveWorkspaceFolderToken(projectPath, folder.uri.fsPath);
projectPath = resolveVariableTokens(projectPath, folder.uri.fsPath);
}

const dotnetDebugServiceProxy = await getServiceBroker()?.getProxy<IDotnetDebugConfigurationService>(
Expand Down
Loading