From c85d76961206d1089b803c0b98655a07c7ce4ecc Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 13 Nov 2019 13:40:42 -0600 Subject: [PATCH] Miscellaneous fixes (#1422) * NPS survey after 5 sessions * Fix path normalization issue * Improve F5 behavior without configs * Add gitattributes --- .gitattributes | 2 ++ .../DockerDebugConfigurationProvider.ts | 21 +++++++++++++++++-- ...dockerNetCoreDebugConfigurationProvider.ts | 19 ++++++++++++++++- src/debugging/netcore/NetCoreDebugHelper.ts | 8 ++++--- src/tasks/netcore/updateBlazorManifest.ts | 2 +- src/utils/nps.ts | 2 +- 6 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..ecf6dba8ef --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Stop git from breaking this script by putting CRLF in place of LF +resources/vsdbg text eol=lf diff --git a/src/debugging/DockerDebugConfigurationProvider.ts b/src/debugging/DockerDebugConfigurationProvider.ts index 433d0edda5..ac2522525b 100644 --- a/src/debugging/DockerDebugConfigurationProvider.ts +++ b/src/debugging/DockerDebugConfigurationProvider.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See LICENSE.md in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { CancellationToken, debug, DebugConfiguration, DebugConfigurationProvider, ProviderResult, WorkspaceFolder } from 'vscode'; +import { CancellationToken, commands, debug, DebugConfiguration, DebugConfigurationProvider, MessageItem, ProviderResult, window, WorkspaceFolder } from 'vscode'; import { callWithTelemetryAndErrorHandling, IActionContext } from 'vscode-azureextensionui'; import { DockerOrchestration } from '../constants'; import { getAssociatedDockerRunTask } from '../tasks/TaskHelper'; @@ -24,7 +24,18 @@ export class DockerDebugConfigurationProvider implements DebugConfigurationProvi ) { } public provideDebugConfigurations(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult { - return undefined; + const add: MessageItem = { title: 'Add Docker Files' }; + + // Prompt them to add Docker files since they probably haven't + window.showErrorMessage( + 'To debug in a Docker container on supported platforms, use the command \"Docker: Add Docker Files to Workspace\", or click \"Add Docker Files\".', + ...[add]).then((result) => { + if (result === add) { + commands.executeCommand('vscode-docker.configure'); + } + }); + + return []; } public resolveDebugConfiguration(folder: WorkspaceFolder | undefined, debugConfiguration: DockerDebugConfiguration, token?: CancellationToken): ProviderResult { @@ -35,6 +46,12 @@ export class DockerDebugConfigurationProvider implements DebugConfigurationProvi throw new Error('To debug with Docker you must first open a folder or workspace in VS Code.'); } + if (debugConfiguration.type === undefined) { + // If type is undefined, they may be doing F5 without creating any real launch.json, which won't work + // VSCode subsequently will call provideDebugConfigurations which will show an error message + return null; + } + const debugPlatform = getPlatform(debugConfiguration); actionContext.telemetry.properties.platform = debugPlatform; actionContext.telemetry.properties.orchestration = 'single' as DockerOrchestration; // TODO: docker-compose, when support is added diff --git a/src/debugging/coreclr/dockerNetCoreDebugConfigurationProvider.ts b/src/debugging/coreclr/dockerNetCoreDebugConfigurationProvider.ts index 716e7c5773..3b523439a2 100644 --- a/src/debugging/coreclr/dockerNetCoreDebugConfigurationProvider.ts +++ b/src/debugging/coreclr/dockerNetCoreDebugConfigurationProvider.ts @@ -4,7 +4,7 @@ import * as fse from 'fs-extra'; import * as path from 'path'; -import { CancellationToken, DebugConfiguration, DebugConfigurationProvider, ProviderResult, WorkspaceFolder } from 'vscode'; +import { CancellationToken, commands, DebugConfiguration, DebugConfigurationProvider, MessageItem, ProviderResult, window, WorkspaceFolder } from 'vscode'; import { callWithTelemetryAndErrorHandling } from 'vscode-azureextensionui'; import { PlatformOS } from '../../utils/platform'; import { resolveVariables } from '../../utils/resolveVariables'; @@ -73,6 +73,17 @@ export class DockerNetCoreDebugConfigurationProvider implements DebugConfigurati } public provideDebugConfigurations(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult { + const add: MessageItem = { title: 'Add Docker Files' }; + + // Prompt them to add Docker files since they probably haven't + window.showErrorMessage( + 'To debug in a Docker container on supported platforms, use the command \"Docker: Add Docker Files to Workspace\", or click \"Add Docker Files\".', + ...[add]).then((result) => { + if (result === add) { + commands.executeCommand('vscode-docker.configure'); + } + }); + return []; } @@ -87,6 +98,12 @@ export class DockerNetCoreDebugConfigurationProvider implements DebugConfigurati throw new Error('No workspace folder is associated with debugging.'); } + if (debugConfiguration.type === undefined) { + // If type is undefined, they may be doing F5 without creating any real launch.json, which won't work + // VSCode subsequently will call provideDebugConfigurations which will show an error message + return null; + } + const { appFolder, resolvedAppFolder } = await this.inferAppFolder(folder, debugConfiguration); const { resolvedAppProject } = await this.inferAppProject(folder, debugConfiguration, resolvedAppFolder); diff --git a/src/debugging/netcore/NetCoreDebugHelper.ts b/src/debugging/netcore/NetCoreDebugHelper.ts index 51943d8e82..5c3f95fa56 100644 --- a/src/debugging/netcore/NetCoreDebugHelper.ts +++ b/src/debugging/netcore/NetCoreDebugHelper.ts @@ -222,9 +222,11 @@ export class NetCoreDebugHelper implements DebugHelper { private static getContainerAppOutput(debugConfiguration: DockerDebugConfiguration, appOutput: string, platformOS: PlatformOS): string { const relativePath = path.relative(path.dirname(debugConfiguration.netCore.appProject), appOutput); - return platformOS === 'Windows' ? - pathNormalize(path.win32.join('C:\\app', relativePath)) : - pathNormalize(path.posix.join('/app', relativePath)); + let result = platformOS === 'Windows' ? + path.win32.join('C:\\app', relativePath) : + path.posix.join('/app', relativePath); + + return pathNormalize(result, platformOS); } } diff --git a/src/tasks/netcore/updateBlazorManifest.ts b/src/tasks/netcore/updateBlazorManifest.ts index 80c72a4a7e..2de834701e 100644 --- a/src/tasks/netcore/updateBlazorManifest.ts +++ b/src/tasks/netcore/updateBlazorManifest.ts @@ -41,7 +41,7 @@ export async function updateBlazorManifest(context: DockerRunTaskContext, runDef const targetsFile = path.join(ext.context.asAbsolutePath('resources'), 'GetBlazorManifestLocations.targets'); - const command = `dotnet build /r:false /t:GetBlazorManifestLocations /p:CustomAfterMicrosoftCommonTargets=${targetsFile} /p:BlazorManifestLocationsOutput=${locationsFile} ${runDefinition.netCore.appProject}`; + const command = `dotnet build /r:false /t:GetBlazorManifestLocations /p:CustomAfterMicrosoftCommonTargets="${targetsFile}" /p:BlazorManifestLocationsOutput="${locationsFile}" "${runDefinition.netCore.appProject}"`; try { await execAsync(command, { timeout: 5000 }); diff --git a/src/utils/nps.ts b/src/utils/nps.ts index b793080891..9372e3f2d7 100644 --- a/src/utils/nps.ts +++ b/src/utils/nps.ts @@ -9,7 +9,7 @@ import { env, Memento, Uri, window } from "vscode"; import { ext } from "vscode-azureappservice/out/src/extensionVariables"; const PROBABILITY = 0.15; -const MIN_SESSION_COUNT = 10; +const MIN_SESSION_COUNT = 5; const SURVEY_NAME = 'nps1'; const SURVEY_URL = 'https://aka.ms/vscodedockernpsinproduct';