diff --git a/.gitignore b/.gitignore index 51f48c4cf..fab283481 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ out .razorExtension/ .vscode-test/ .roslynCopilot/ +.testDiscovery/ msbuild/signing/signJs/*.log msbuild/signing/signVsix/*.log dist/ diff --git a/package.json b/package.json index 3752f98b0..d579c6e04 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "roslyn": "5.9.0-1.26303.15", "omniSharp": "1.39.14", "razorOmnisharp": "7.0.0-preview.23363.1", - "xamlTools": "18.9.11909.33" + "xamlTools": "18.9.11909.33", + "testDiscovery": "0.1.0-dev" }, "main": "./dist/extension", "l10n": "./l10n", @@ -1479,6 +1480,10 @@ "roslynCopilot": { "description": "%configuration.dotnet.server.componentPaths.roslynCopilot%", "type": "string" + }, + "testDiscovery": { + "description": "%configuration.dotnet.server.componentPaths.testDiscovery%", + "type": "string" } }, "default": {} diff --git a/package.nls.json b/package.nls.json index b11039058..224e27a3d 100644 --- a/package.nls.json +++ b/package.nls.json @@ -35,6 +35,7 @@ "configuration.dotnet.server.componentPaths.roslynDevKit": "Overrides the folder path for the .roslynDevKit component of the language server", "configuration.dotnet.server.componentPaths.xamlTools": "Overrides the folder path for the .xamlTools component of the language server", "configuration.dotnet.server.componentPaths.roslynCopilot": "Overrides the folder path for the .roslynCopilot component of the language server", + "configuration.dotnet.server.componentPaths.testDiscovery": "Overrides the folder path for the .testDiscovery component of the language server", "configuration.dotnet.server.componentPaths.razorExtension": "Overrides the folder path for the Razor extension component of the language server", "configuration.dotnet.server.startTimeout": "Specifies a timeout (in ms) for the client to successfully start and connect to the language server.", "configuration.dotnet.server.waitForDebugger": "Passes the --debug flag when launching the server to allow a debugger to be attached. (Requires extension restart)", diff --git a/src/lsptoolshost/extensions/builtInComponents.ts b/src/lsptoolshost/extensions/builtInComponents.ts index 29ec6508c..26d170326 100644 --- a/src/lsptoolshost/extensions/builtInComponents.ts +++ b/src/lsptoolshost/extensions/builtInComponents.ts @@ -35,6 +35,12 @@ export const componentInfo: { [key: string]: ComponentInfo } = { componentDllPaths: ['Microsoft.VisualStudio.Copilot.Roslyn.LanguageServer.dll'], isOptional: true, }, + testDiscovery: { + defaultFolderName: '.testDiscovery', + optionName: 'testDiscovery', + componentDllPaths: ['Microsoft.VisualStudio.CSharpDevKit.SourceTestDiscovery.dll'], + isOptional: true, + }, }; export function getComponentPaths( diff --git a/src/lsptoolshost/server/roslynLanguageServer.ts b/src/lsptoolshost/server/roslynLanguageServer.ts index e9fa5333a..b2c896e6f 100644 --- a/src/lsptoolshost/server/roslynLanguageServer.ts +++ b/src/lsptoolshost/server/roslynLanguageServer.ts @@ -928,6 +928,16 @@ export class RoslynLanguageServer { ); } + // Also include the C# Dev Kit source-based test discovery extension, if present. The component + // is built by C# Dev Kit (vs-green), published as a NuGet package, and restored into this + // extension at build time (see allNugetPackages in offlinePackagingTasks.ts), using the same + // mechanism as the Xaml tools and roslynDevKit components above. It is optional: builds + // that don't restore the package won't have the folder, in which case getComponentPaths returns + // an empty array and we skip it. The consumer of the discovery service is the C# Dev Kit server. + getComponentPaths('testDiscovery', languageServerOptions, channel).forEach((path) => + additionalExtensionPaths.push(path) + ); + return args; } diff --git a/tasks/packaging/offlinePackagingTasks.ts b/tasks/packaging/offlinePackagingTasks.ts index b74b66964..a31034395 100644 --- a/tasks/packaging/offlinePackagingTasks.ts +++ b/tasks/packaging/offlinePackagingTasks.ts @@ -23,6 +23,7 @@ import { rootPath, devKitDependenciesDirectory, xamlToolsDirectory, + testDiscoveryDirectory, } from '../projectPaths'; import { getPackageJSON } from '../packageJson'; import { createPackageAsync, generateVsixManifest } from './vsceTasks'; @@ -91,6 +92,12 @@ export const allNugetPackages: { [key: string]: NugetPackageInfo } = { getPackageContentPath: (_platformInfo) => 'content', vsixOutputPath: xamlToolsDirectory, }, + testDiscovery: { + getPackageName: (_platformInfo) => 'Microsoft.VisualStudio.CSharpDevKit.SourceTestDiscovery', + packageJsonName: 'testDiscovery', + getPackageContentPath: (_platformInfo) => 'content', + vsixOutputPath: testDiscoveryDirectory, + }, }; interface PlatformEntry { diff --git a/tasks/projectPaths.ts b/tasks/projectPaths.ts index a2362f9b0..0972ed0bf 100644 --- a/tasks/projectPaths.ts +++ b/tasks/projectPaths.ts @@ -18,6 +18,7 @@ export const nugetTempPath = path.join(rootPath, 'out', '.nuget'); export const languageServerDirectory = path.join(rootPath, '.roslyn'); export const devKitDependenciesDirectory = path.join(rootPath, componentInfo.roslynDevKit.defaultFolderName); export const xamlToolsDirectory = path.join(rootPath, componentInfo.xamlTools.defaultFolderName); +export const testDiscoveryDirectory = path.join(rootPath, componentInfo.testDiscovery.defaultFolderName); export const codeExtensionPath = commandLineOptions.codeExtensionPath || rootPath;