Skip to content

Commit

Permalink
Miscellaneous fixes (#1422)
Browse files Browse the repository at this point in the history
* NPS survey after 5 sessions

* Fix path normalization issue

* Improve F5 behavior without configs

* Add gitattributes
  • Loading branch information
bwateratmsft committed Nov 13, 2019
1 parent 363d88e commit c85d769
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
@@ -0,0 +1,2 @@
# Stop git from breaking this script by putting CRLF in place of LF
resources/vsdbg text eol=lf
21 changes: 19 additions & 2 deletions src/debugging/DockerDebugConfigurationProvider.ts
Expand Up @@ -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';
Expand All @@ -24,7 +24,18 @@ export class DockerDebugConfigurationProvider implements DebugConfigurationProvi
) { }

public provideDebugConfigurations(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugConfiguration[]> {
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<DebugConfiguration | undefined> {
Expand All @@ -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
Expand Down
19 changes: 18 additions & 1 deletion src/debugging/coreclr/dockerNetCoreDebugConfigurationProvider.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -73,6 +73,17 @@ export class DockerNetCoreDebugConfigurationProvider implements DebugConfigurati
}

public provideDebugConfigurations(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugConfiguration[]> {
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 [];
}

Expand All @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions src/debugging/netcore/NetCoreDebugHelper.ts
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/tasks/netcore/updateBlazorManifest.ts
Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion src/utils/nps.ts
Expand Up @@ -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';
Expand Down

0 comments on commit c85d769

Please sign in to comment.