Skip to content
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

Create Attach config for dotnet core compose #1652

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions src/configureWorkspace/configureDotNetCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,15 @@ async function findCSProjOrFSProjFile(folderPath?: string): Promise<string> {
}
}

async function initializeForDebugging(context: IActionContext, folder: WorkspaceFolder, platformOS: PlatformOS, workspaceRelativeDockerfileName: string, workspaceRelativeProjectFileName: string): Promise<void> {
async function initializeForDebugging(context: IActionContext, folder: WorkspaceFolder, platformOS: PlatformOS, isCompose: boolean, workspaceRelativeDockerfileName: string, workspaceRelativeProjectFileName: string): Promise<void> {
const scaffoldContext: DockerDebugScaffoldContext = {
folder: folder,
platform: 'netCore',
actionContext: context,
// always use posix for debug config because it's committed to source control and works on all OS's
/* eslint-disable-next-line no-template-curly-in-string */
dockerfile: path.posix.join('${workspaceFolder}', workspaceRelativeDockerfileName),
isCompose: isCompose
}

const options: NetCoreScaffoldingOptions = {
Expand Down Expand Up @@ -442,7 +443,7 @@ export async function scaffoldNetCore(context: ScaffolderContext): Promise<Scaff
const dockerFilePath = path.resolve(context.rootFolder, dockerFileName);
const workspaceRelativeDockerfileName = path.relative(context.folder.uri.fsPath, dockerFilePath);

await initializeForDebugging(context, context.folder, context.os, workspaceRelativeDockerfileName, workspaceRelativeProjectFileName);
await initializeForDebugging(context, context.folder, context.os, isCompose, workspaceRelativeDockerfileName, workspaceRelativeProjectFileName);
}

return files;
Expand Down
36 changes: 25 additions & 11 deletions src/debugging/netcore/NetCoreDebugHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,32 @@ export class NetCoreDebugHelper implements DebugHelper {
public async provideDebugConfigurations(context: DockerDebugScaffoldContext, options?: NetCoreDebugScaffoldingOptions): Promise<DockerDebugConfiguration[]> {
options = options || {};
options.appProject = options.appProject || await NetCoreTaskHelper.inferAppProject(context.folder); // This method internally checks the user-defined input first

return [
{
name: 'Docker .NET Core Launch',
type: 'docker',
request: 'launch',
preLaunchTask: 'docker-run: debug',
netCore: {
appProject: unresolveWorkspaceFolder(options.appProject, context.folder)
}
let debugConfigurations : DockerDebugConfiguration[] = [{
Copy link
Collaborator

@bwateratmsft bwateratmsft Feb 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would if/else this. The .NET Core launch config probably not work in the expected way if a compose file is present (i.e. it will not use compose at all, users might be confused by this). Also, if compose I would also not add the docker-build / docker-run tasks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. Why would single not work if compose file is present?

name: 'Docker .NET Core Launch',
type: 'docker',
request: 'launch',
preLaunchTask: 'docker-run: debug',
netCore: {
appProject: unresolveWorkspaceFolder(options.appProject, context.folder)
}
];
}];

if (context.isCompose) {
debugConfigurations.push(
{
name: 'Docker .NET Core Attach (Preview)',
type: 'docker',
request: 'attach',
platform: 'netCore',
sourceFileMap: {
// eslint-disable-next-line no-template-curly-in-string
'/src': '${workspaceFolder}'
}
}
);
}

return debugConfigurations;
}

public async resolveDebugConfiguration(context: DockerDebugContext, debugConfiguration: DockerDebugConfiguration): Promise<ResolvedDebugConfiguration | undefined> {
Expand Down
1 change: 1 addition & 0 deletions src/tasks/TaskHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function throwIfCancellationRequested(context: DockerTaskContext): void {
export interface DockerTaskScaffoldContext extends DockerTaskContext {
dockerfile: string;
ports?: number[];
isCompose?: boolean;
}

export interface DockerTaskExecutionContext extends DockerTaskContext {
Expand Down