mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 17:22:45 -05:00
Get tools service install location from extensions (#16796)
* Get STS install location from extensions * Update error
This commit is contained in:
@@ -262,7 +262,7 @@ export function invalidInput(input: string) { return localize('invalidInput', "I
|
||||
export function invalidProjectPropertyValue(propertyName: string) { return localize('invalidPropertyValue', "Invalid value specified for the property '{0}' in .sqlproj file", propertyName); }
|
||||
export function unableToCreatePublishConnection(input: string) { return localize('unableToCreatePublishConnection', "Unable to construct connection: {0}", input); }
|
||||
export function circularProjectReference(project1: string, project2: string) { return localize('cicularProjectReference', "Circular reference from project {0} to project {1}", project1, project2); }
|
||||
export function sqlToolsServiceNotFound(sqlToolsServiceDir: string) { return localize('mssqlNotFound', "Could not get SQL Tools Service install location at {0}", sqlToolsServiceDir); }
|
||||
export function errorFindingBuildFilesLocation(err: any) { return localize('errorFindingBuildFilesLocation', "Error finding build files location: {0}", utils.getErrorMessage(err)); }
|
||||
export function projBuildFailed(errorMessage: string) { return localize('projBuildFailed', "Build failed. Check output pane for more details. {0}", errorMessage); }
|
||||
export function unexpectedProjectContext(uri: string) { return localize('unexpectedProjectContext', "Unable to establish project context. Command invoked from unexpected location: {0}", uri); }
|
||||
export function unableToPerformAction(action: string, uri: string) { return localize('unableToPerformAction', "Unable to locate '{0}' target: '{1}'", action, uri); }
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import { promises as fs } from 'fs';
|
||||
import * as utils from '../common/utils';
|
||||
import { sqlToolsServiceNotFound } from '../common/constants';
|
||||
import { errorFindingBuildFilesLocation } from '../common/constants';
|
||||
import * as mssql from '../../../mssql/src/mssql';
|
||||
import * as vscodeMssql from 'vscode-mssql';
|
||||
import * as sqldbproj from 'sqldbproj';
|
||||
@@ -66,41 +65,15 @@ export class BuildHelper {
|
||||
* @returns
|
||||
*/
|
||||
private async getBuildDirPathFromMssqlTools(): Promise<string> {
|
||||
let mssqlConfigDir = '';
|
||||
if (utils.getAzdataApi()) {
|
||||
mssqlConfigDir = vscode.extensions.getExtension(mssql.extension.name)?.extensionPath ?? '';
|
||||
} else {
|
||||
// VS Code MSSQL extension has its tools service config in a slightly different spot
|
||||
mssqlConfigDir = path.join(vscode.extensions.getExtension(vscodeMssql.extension.name)?.extensionPath ?? '', 'out', 'src');
|
||||
}
|
||||
|
||||
if (await utils.exists(path.join(mssqlConfigDir, 'config.json'))) {
|
||||
const rawConfig = await fs.readFile(path.join(mssqlConfigDir, 'config.json'));
|
||||
const config = JSON.parse(rawConfig.toString());
|
||||
let installDir = '';
|
||||
try {
|
||||
if (utils.getAzdataApi()) {
|
||||
installDir = config.installDirectory?.replace('{#version#}', config.version).replace('{#platform#}', this.getPlatform());
|
||||
return (vscode.extensions.getExtension(mssql.extension.name)?.exports as mssql.IExtension).sqlToolsServicePath;
|
||||
} else {
|
||||
// VS Code MSSQL extension has a slightly different format for its config.json
|
||||
installDir = config.service?.installDir?.replace('{#version#}', config.service.version).replace('{#platform#}', this.getPlatform());
|
||||
if (installDir) {
|
||||
// The path to the install location is relative to one directory above where the config is so account for that here
|
||||
installDir = path.join('..', installDir);
|
||||
}
|
||||
}
|
||||
|
||||
if (installDir) {
|
||||
return path.join(mssqlConfigDir, installDir);
|
||||
return (vscode.extensions.getExtension(vscodeMssql.extension.name)?.exports as vscodeMssql.IExtension).sqlToolsServicePath;
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error(errorFindingBuildFilesLocation(err));
|
||||
}
|
||||
throw new Error(sqlToolsServiceNotFound(mssqlConfigDir));
|
||||
}
|
||||
|
||||
private getPlatform(): string {
|
||||
return os.platform() === 'win32' ? 'Windows' :
|
||||
os.platform() === 'darwin' ? 'OSX' :
|
||||
os.platform() === 'linux' ? 'Linux' :
|
||||
'';
|
||||
}
|
||||
|
||||
public get extensionBuildDirPath(): string {
|
||||
|
||||
@@ -24,6 +24,11 @@ declare module 'vscode-mssql' {
|
||||
*/
|
||||
export interface IExtension {
|
||||
|
||||
/**
|
||||
* Path to the root of the SQL Tools Service folder
|
||||
*/
|
||||
readonly sqlToolsServicePath: string;
|
||||
|
||||
/**
|
||||
* Service for accessing DacFx functionality
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user