diff --git a/CHANGELOG.md b/CHANGELOG.md index fef04c1c5..8476a409a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## Known Issues in 1.25.0 +## Known Issues in 1.25.1 * For Mono-based development (e.g. Unity) that requires full .NET framework, you need to set `"omnisharp.useModernNet": false`. * After selecting a solution filter (*.slnf) from the project selector, the solution's name will be displayed in the status bar instead of the filter's. @@ -12,7 +12,10 @@ * Renaming symbol fails within a file that had recently been renamed without saving changes. * As a workaround, make an edit within the file before using Rename Symbol. -## 1.25.0 +## 1.25.1 +* Provide actionable error messages for .NET SDK issues ([#5223](https://github.com/OmniSharp/omnisharp-vscode/issues/5223), PR: [#5225](https://github.com/OmniSharp/omnisharp-vscode/pull/5225)) + +## 1.25.0 (May 24th, 2022) * Make SDK build of OmniSharp the default ([#5120](https://github.com/OmniSharp/omnisharp-vscode/issues/5120), PR: [#5176](https://github.com/OmniSharp/omnisharp-vscode/pull/5176)) * Add auto complete name to class, interface, enum, struct etc. snippets (PR: [#5198](https://github.com/OmniSharp/omnisharp-vscode/pull/5198)) * Add a fallback for ps in remoteProcessPickerScript ([#4096](https://github.com/OmniSharp/omnisharp-vscode/issues/4096), PR: [#5207](https://github.com/OmniSharp/omnisharp-vscode/pull/5207)) diff --git a/README.md b/README.md index 0189f68d7..411234428 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,9 @@ If you still need Unity or .NET Framework support, you can set `omnisharp.useMod See issue [#5120](https://github.com/OmniSharp/omnisharp-vscode/issues/5120) for more details. +## What's new in 1.25.1 +* Provide actionable error messages for .NET SDK issues ([#5223](https://github.com/OmniSharp/omnisharp-vscode/issues/5223), PR: [#5225](https://github.com/OmniSharp/omnisharp-vscode/pull/5225)) + ## What's new in 1.25.0 * Make SDK build of OmniSharp the default ([#5120](https://github.com/OmniSharp/omnisharp-vscode/issues/5120), PR: [#5176](https://github.com/OmniSharp/omnisharp-vscode/pull/5176)) * Add auto complete name to class, interface, enum, struct etc. snippets (PR: [#5198](https://github.com/OmniSharp/omnisharp-vscode/pull/5198)) diff --git a/package-lock.json b/package-lock.json index 7ab57a760..9ab0bbeed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "csharp", - "version": "1.25.0", + "version": "1.25.1", "lockfileVersion": 2, "requires": true, "packages": { @@ -16798,4 +16798,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index b87e539b9..144c31b1f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csharp", "publisher": "ms-dotnettools", - "version": "1.25.0", + "version": "1.25.1", "description": "C# for Visual Studio Code (powered by OmniSharp).", "displayName": "C#", "author": "Microsoft Corporation", diff --git a/src/main.ts b/src/main.ts index 0e3d9d5ec..b161aed58 100644 --- a/src/main.ts +++ b/src/main.ts @@ -57,6 +57,15 @@ export async function activate(context: vscode.ExtensionContext): Promise"; diff --git a/src/observers/OmnisharpLoggerObserver.ts b/src/observers/OmnisharpLoggerObserver.ts index 274a79c84..664f8c1ca 100644 --- a/src/observers/OmnisharpLoggerObserver.ts +++ b/src/observers/OmnisharpLoggerObserver.ts @@ -7,8 +7,15 @@ import { BaseLoggerObserver } from "./BaseLoggerObserver"; import { BaseEvent, OmnisharpInitialisation, OmnisharpLaunch, OmnisharpFailure, OmnisharpServerMessage, OmnisharpServerOnServerError, OmnisharpServerOnError, OmnisharpServerMsBuildProjectDiagnostics, OmnisharpServerOnStdErr, OmnisharpEventPacketReceived } from "../omnisharp/loggingEvents"; import * as os from 'os'; import { EventType } from "../omnisharp/EventType"; +import * as vscode from 'vscode'; +import { PlatformInformation } from "../platform"; +import { Logger } from "../logger"; export class OmnisharpLoggerObserver extends BaseLoggerObserver { + constructor(channel: vscode.OutputChannel | Logger, private platformInformation: PlatformInformation) { + super(channel); + } + public post = (event: BaseEvent) => { switch (event.type) { case EventType.OmnisharpInitialisation: @@ -34,7 +41,7 @@ export class OmnisharpLoggerObserver extends BaseLoggerObserver { this.handleOmnisharpServerMsBuildProjectDiagnostics(event); break; case EventType.OmnisharpServerOnStdErr: - this.logger.append((event).message); + this.handleOmnisharpServerOnStdErr(event); break; case EventType.OmnisharpEventPacketReceived: this.handleOmnisharpEventPacketReceived(event); @@ -43,9 +50,27 @@ export class OmnisharpLoggerObserver extends BaseLoggerObserver { } private handleOmnisharpServerOnServerError(event: OmnisharpServerOnServerError) { + if (event.err.cmd === "dotnet --version") { + this.logger.appendLine('[ERROR] A .NET 6 SDK was not found. Please install the latest SDK from https://dotnet.microsoft.com/en-us/download/dotnet/6.0.'); + return; + } + else if (event.err.message?.startsWith("Found dotnet version")) { + this.logger.appendLine(`[ERROR] ${event.err} Please install the latest SDK from https://dotnet.microsoft.com/en-us/download/dotnet/6.0.`); + return; + } + this.logger.appendLine('[ERROR] ' + event.err); } + private handleOmnisharpServerOnStdErr(event: OmnisharpServerOnStdErr) { + if (event.message.startsWith("System.BadImageFormatException: Could not load file or assembly")) { + this.logger.appendLine(`[ERROR] A .NET 6 SDK for ${this.platformInformation.architecture} was not found. Please install the latest ${this.platformInformation.architecture} SDK from https://dotnet.microsoft.com/en-us/download/dotnet/6.0.`); + return; + } + + this.logger.appendLine('[STDERR] ' + event.message); + } + private handleOmnisharpInitialisation(event: OmnisharpInitialisation) { this.logger.appendLine(`Starting OmniSharp server at ${event.timeStamp.toLocaleString()}`); this.logger.increaseIndent(); diff --git a/test/unitTests/logging/OmnisharpLoggerObserver.test.ts b/test/unitTests/logging/OmnisharpLoggerObserver.test.ts index 2d799bd3c..3ec769cd3 100644 --- a/test/unitTests/logging/OmnisharpLoggerObserver.test.ts +++ b/test/unitTests/logging/OmnisharpLoggerObserver.test.ts @@ -6,14 +6,20 @@ import { should, expect } from 'chai'; import { getNullChannel } from '../testAssets/Fakes'; import { OmnisharpLoggerObserver } from '../../../src/observers/OmnisharpLoggerObserver'; import { OmnisharpServerMsBuildProjectDiagnostics, EventWithMessage, OmnisharpServerOnStdErr, OmnisharpServerMessage, OmnisharpServerOnServerError, OmnisharpInitialisation, OmnisharpLaunch, OmnisharpServerOnError, OmnisharpFailure, OmnisharpEventPacketReceived } from '../../../src/omnisharp/loggingEvents'; +import { OutputChannel } from 'vscode'; +import { PlatformInformation } from '../../../src/platform'; suite("OmnisharpLoggerObserver", () => { suiteSetup(() => should()); let logOutput = ""; - let observer = new OmnisharpLoggerObserver({ + let channel = { ...getNullChannel(), - append: (text: string) => { logOutput += text; }, + append: (text: string) => { logOutput += text; } + }; + let observer = new OmnisharpLoggerObserver(channel, { + architecture: "x128", + platform: "TestOS" }); setup(() => {