Trying to completely remove the BlazorWasmDebuggingExtension and getting URL information from launchSettings.json

This commit is contained in:
Thays Grazia 2023-02-09 17:29:48 -03:00
Родитель e5ba64df5b
Коммит 2ed214a75f
17 изменённых файлов: 23 добавлений и 1603 удалений

3
.github/CODEOWNERS поставляемый
Просмотреть файл

@ -7,7 +7,6 @@
/eng/common/ @dotnet/razor-tooling @dotnet/razor-compiler
/eng/Versions.props @dotnet/razor-tooling @dotnet/razor-compiler
/eng/Version.Details.xml @dotnet/razor-tooling @dotnet/razor-compiler
/src/Razor/src/Microsoft.AspNetCore.Razor.VSCode.BlazorWasmDebuggingExtension/ @dotnet/razor-tooling @captainsafia
/src/Razor @dotnet/razor-tooling
/src/Razor @dotnet/razor-tooling
/src/Compiler @dotnet/razor-compiler
/src/Shared @dotnet/razor-tooling @dotnet/razor-compiler

Просмотреть файл

@ -255,16 +255,6 @@ stages:
continueOnError: true
condition: always()
- powershell: |
$version = $(node -p "require('./package.json').version" | Out-String).Trim()
yarn install
md $(Build.SourcesDirectory)/artifacts/packages/VSCode/$(_BuildConfig)/ -ea 0
npx vsce@1.103.1 package -o $(Build.SourcesDirectory)/artifacts/packages/VSCode/$(_BuildConfig)/blazorwasm-companion-$version.vsix
displayName: Produce Blazor WASM Debugging Extension VSIX
workingDirectory: $(Build.SourcesDirectory)/src/Razor/src/Microsoft.AspNetCore.Razor.VSCode.BlazorWasmDebuggingExtension
failOnStderr: true
condition: and(succeeded(), eq(variables['_BuildConfig'], 'Release'))
- task: PublishBuildArtifacts@1
displayName: Upload Test Results
condition: always()
@ -309,14 +299,6 @@ stages:
continueOnError: true
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false), eq(variables['_BuildConfig'], 'Release'))
- task: PublishBuildArtifacts@1
displayName: Publish VS Code extension artifacts
inputs:
PathtoPublish: 'artifacts\packages\VSCode\$(_BuildConfig)'
ArtifactName: BlazorWasmDebuggingExtension
continueOnError: true
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false), eq(variables['_BuildConfig'], 'Release'))
- powershell: Write-Host "##vso[task.setvariable variable=VisualStudio.DropName]Products/$(System.TeamProject)/$(Build.Repository.Name)/$(Build.SourceBranchName)/$(Build.BuildNumber)"
displayName: Setting VisualStudio.DropName variable

Просмотреть файл

@ -1,2 +0,0 @@
# Auto generated file from Gardener Plugin CentralFeedServiceAdoptionPlugin
registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/

Просмотреть файл

@ -1,12 +0,0 @@
.vscode/**
.vscode-test/**
out/test/**
src/**
.gitignore
.yarnrc
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts
scripts/**

Просмотреть файл

@ -1 +0,0 @@
--ignore-engines true

Просмотреть файл

@ -1,23 +0,0 @@
The MIT License (MIT)
Copyright (c) .NET Foundation and Contributors
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Просмотреть файл

@ -1,16 +0,0 @@
<Project DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<BuildOutputFiles Include="dist\extension.js" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
</Project>

Просмотреть файл

@ -1,30 +0,0 @@
# Microsoft.AspNetCore.Razor.VSCode.BlazorWasmDebuggingExtension
**Warning:** This extension is intended for use alongside the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp).
This directory contains the code for the Blazor WebAssembly Debugging extension. This extension is designed to support debugging scenarios for Blazor WebAssembly.
Blazor WebAssembly runs in the browser via a .NET runtime running on WebAssembly. As a result, the traditional infrastructure that is used to debug .NET applications cannot be used for Blazor WebAssembly. Instead, Blazor WebAssembly leverages a debugging proxy that communicates with a web browser and IDE over the Chrome DevTools Protocol.
This debugging proxy is typically launched by the the Blazor development server wherever the Blazor server is running. This experience works fine for "local dev" scenarios where the developer is running their browser, the IDE, and the Blazor development server on the same machine.
In remote debugging scenarios, the browser, IDE, and server hosting the Blazor app are running on different machines.
- The browser runs on the user's host machine.
- The server hosting the Blazor app and debugging proxy run in the remote environment (Docker container, WSL, Codespaces)
- VS Code runs in a dual-mode with some extension (UI extensions) running on the host machine and some extensions running on the remote machine (workspace extensions)
The debugging proxy needs to talk to both VS Code and the browser but they run in different places. In particular, the debugging proxy cannot communicate with the browser from inside the remote machine.
To that end, we need a way to launch the debugging proxy on the user's host machine, where the browser is running. To achieve this, we developed a UI-only extension that runs on the VS Code UI (the same place as the users host) and is responsible for launching and killing a Blazor debugging proxy on the host machine.
## Publishing the extension
In order to publish the extension, you will need to have access to the `ms.dotnet-tools` publisher account on the VS Code marketplace. If you don't already have this access, reach out to @captainsafia for info.
1. Generate a personal access token per the instructions in [the VS Code publishing guide](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page).
2. Store the token from #1 in the `VSCODE_MARKETPLACE_TOKEN` environment variable.
3. Increment the `patch` version of the package in the `package.json` file.
4. Open a PR to the razor-tooling repo.
5. Download the VSIX asset from the artifiacts of the build.
6. Publish the VSIX asset using `vsix publish --packagePath ${pathFrom5} -p $VSCODE_MARKETPLACE_TOKEN`.

Просмотреть файл

@ -1,7 +0,0 @@
# Microsoft.AspNetCore.Razor.VSCode.BlazorWasmDebuggingExtension
This is a companion extension to the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) that brings some improvements to the experience for debugging Blazor WebAssembly in VS Code. This extension should **not** be installed by itself and will automatically install the C# extension.
For more information on Blazor, visit the [Blazor homepage](https://blazor.net).
For more information on debugging Blazor WebAssembly applications, vist our official documentation page on [debugging Blazor WASM](https://docs.microsoft.com/aspnet/core/blazor/debug).

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 2.0 KiB

Просмотреть файл

@ -1,67 +0,0 @@
{
"name": "blazorwasm-companion",
"displayName": "Microsoft.AspNetCore.Razor.VSCode.BlazorWasmDebuggingExtension",
"description": "A companion extension for debugging Blazor WebAssembly applications in VS Code. Must be installed alongside the C# extension.",
"version": "1.1.4",
"repository": {
"type": "git",
"url": "https://github.com/dotnet/razor.git"
},
"license": "MIT",
"engines": {
"vscode": "^1.69.0"
},
"icon": "images/blazorIcon.png",
"dotnetRuntimeVersion": "6.0",
"debugProxyVersion": "6.0.1",
"categories": [
"Other"
],
"extensionKind": [
"ui"
],
"publisher": "ms-dotnettools",
"activationEvents": [
"onCommand:blazorwasm-companion.launchDebugProxy"
],
"main": "./dist/extension.js",
"extensionDependencies": [
"ms-dotnettools.vscode-dotnet-runtime",
"ms-dotnettools.csharp"
],
"capabilities": {
"untrustedWorkspaces": {
"supported": true
}
},
"contributes": {},
"scripts": {
"vscode:prepublish": "yarn run build",
"clean": "rimraf dist",
"build": "yarn run clean && yarn run lint && yarn run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "yarn run compile && yarn run lint",
"lint": "tslint --project ./"
},
"devDependencies": {
"@types/glob": "^7.1.3",
"@types/mocha": "^8.0.4",
"@types/node": "^14.18.12",
"@types/vscode": "^1.69.0",
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"extract-zip": "^2.0.1",
"glob": "^7.1.6",
"minimatch": "3.0.5",
"mocha": "^8.1.3",
"node-fetch": "^2.6.7",
"rimraf": "2.6.3",
"tslint": "^5.11.0",
"typescript": "^4.5.4",
"vscode-test": "^1.4.1"
},
"dependencies": {
"nanoid": "^4.0.0"
}
}

Просмотреть файл

@ -1,33 +0,0 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import { readFileSync } from 'fs';
import { join } from 'path';
import { fileURLToPath } from 'url';
import * as vscode from 'vscode';
export async function activate(context: vscode.ExtensionContext) {
const launchDebugProxy = vscode.commands.registerCommand('blazorwasm-companion.launchDebugProxy', async (folder: vscode.WorkspaceFolder, configuration: vscode.DebugConfiguration) => {
try {
let folderPath = configuration.cwd ? configuration.cwd : fileURLToPath(folder.uri.toString());
folderPath = folderPath.replace('${workspaceFolder}', fileURLToPath(folder.uri.toString()));
const launchSettings = JSON.parse(readFileSync(join(folderPath, 'Properties', 'launchSettings.json'), 'utf8'));
if (launchSettings?.profiles && launchSettings?.profiles[Object.keys(launchSettings.profiles)[0]]?.inspectUri) {
return {
inspectUri: launchSettings.profiles[Object.keys(launchSettings.profiles)[0]].inspectUri,
};
}
return {
inspectUri: '{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}',
};
} catch (error: any) {
return {
inspectUri: '{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}',
};
}
});
context.subscriptions.push(launchDebugProxy);
}

Просмотреть файл

@ -1,9 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"./src/**/*"
]
}

Просмотреть файл

@ -1,3 +0,0 @@
{
"extends": "../../tslint.json"
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -14,12 +14,6 @@
SkipGetTargetFrameworkProperties="true"
UndefineProperties="TargetFramework"
Private="false" />
<ProjectReference
Include="..\Microsoft.AspNetCore.Razor.VSCode.BlazorWasmDebuggingExtension\Microsoft.AspNetCore.Razor.VSCode.BlazorWasmDebuggingExtension.npmproj"
ReferenceOutputAssemblies="false"
SkipGetTargetFrameworkProperties="true"
UndefineProperties="TargetFramework"
Private="false" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -2,7 +2,9 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import { readFileSync } from 'fs';
import { join } from 'path';
import { fileURLToPath } from 'url';
import * as vscode from 'vscode';
import { RazorLogger } from '../RazorLogger';
@ -23,17 +25,27 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati
await this.launchApp(folder, configuration);
}
const result = await vscode.commands.executeCommand<{
url: string,
inspectUri: string,
debuggingPort: number,
}>('blazorwasm-companion.launchDebugProxy', folder, configuration);
let inspectUri = '{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}';
let url = 'https://localhost:5001';
try {
if (folder !== undefined) {
let folderPath = configuration.cwd ? configuration.cwd : fileURLToPath(folder.uri.toString());
folderPath = folderPath.replace('${workspaceFolder}', fileURLToPath(folder.uri.toString()));
const launchSettings = JSON.parse(readFileSync(join(folderPath, 'Properties', 'launchSettings.json'), 'utf8'));
if (launchSettings?.profiles && launchSettings?.profiles[Object.keys(launchSettings.profiles)[0]]?.inspectUri) {
inspectUri = launchSettings.profiles[Object.keys(launchSettings.profiles)[0]].inspectUri;
url = launchSettings.profiles[Object.keys(launchSettings.profiles)[0]].applicationUrl;
}
}
} catch (error: any) {
this.logger.logError('[DEBUGGER] Error while getting information from launchSettings.json: ', error as Error);
}
await this.launchBrowser(
folder,
configuration,
result ? result.inspectUri : undefined,
result ? result.debuggingPort : undefined);
inspectUri,
url);
/**
* If `resolveDebugConfiguration` returns undefined, then the debugger
@ -85,18 +97,17 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati
}
}
private async launchBrowser(folder: vscode.WorkspaceFolder | undefined, configuration: vscode.DebugConfiguration, inspectUri?: string, debuggingPort?: number) {
private async launchBrowser(folder: vscode.WorkspaceFolder | undefined, configuration: vscode.DebugConfiguration, inspectUri: string, url: string) {
const browser = {
name: JS_DEBUG_NAME,
type: configuration.browser === 'edge' ? 'pwa-msedge' : 'pwa-chrome',
request: 'launch',
timeout: configuration.timeout || 30000,
url: configuration.url || 'https://localhost:5001',
url: configuration.url || url,
webRoot: configuration.webRoot || '${workspaceFolder}',
inspectUri,
trace: configuration.trace || false,
noDebug: configuration.noDebug || false,
port: debuggingPort,
...configuration.browserConfig,
// When the browser debugging session is stopped, propogate
// this and terminate the debugging session of the Blazor dev server.