mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Required changes to make sql projects extension work with vscode (#22847)
* Update CreateProject api * More updates * Fix a few comments * Address comments * Remove package.json changes * Fix error * Fix testUtil
This commit is contained in:
@@ -415,7 +415,7 @@ export class SqlProjectsService extends BaseService implements mssql.ISqlProject
|
|||||||
/**
|
/**
|
||||||
* Add a SQL object script to a project
|
* Add a SQL object script to a project
|
||||||
* @param projectUri Absolute path of the project, including .sqlproj
|
* @param projectUri Absolute path of the project, including .sqlproj
|
||||||
* @param path Path of the script, including .sql, relative to the .sqlproj
|
* @param path Path of the file, including extension, relative to the .sqlproj
|
||||||
*/
|
*/
|
||||||
public async addNoneItem(projectUri: string, path: string): Promise<azdata.ResultStatus> {
|
public async addNoneItem(projectUri: string, path: string): Promise<azdata.ResultStatus> {
|
||||||
const params: contracts.SqlProjectScriptParams = { projectUri: projectUri, path: path };
|
const params: contracts.SqlProjectScriptParams = { projectUri: projectUri, path: path };
|
||||||
@@ -425,7 +425,7 @@ export class SqlProjectsService extends BaseService implements mssql.ISqlProject
|
|||||||
/**
|
/**
|
||||||
* Delete a SQL object script from a project
|
* Delete a SQL object script from a project
|
||||||
* @param projectUri Absolute path of the project, including .sqlproj
|
* @param projectUri Absolute path of the project, including .sqlproj
|
||||||
* @param path Path of the script, including .sql, relative to the .sqlproj
|
* @param path Path of the file, including extension, relative to the .sqlproj
|
||||||
*/
|
*/
|
||||||
public async deleteNoneItem(projectUri: string, path: string): Promise<azdata.ResultStatus> {
|
public async deleteNoneItem(projectUri: string, path: string): Promise<azdata.ResultStatus> {
|
||||||
const params: contracts.SqlProjectScriptParams = { projectUri: projectUri, path: path };
|
const params: contracts.SqlProjectScriptParams = { projectUri: projectUri, path: path };
|
||||||
@@ -435,7 +435,7 @@ export class SqlProjectsService extends BaseService implements mssql.ISqlProject
|
|||||||
/**
|
/**
|
||||||
* Exclude a SQL object script from a project
|
* Exclude a SQL object script from a project
|
||||||
* @param projectUri Absolute path of the project, including .sqlproj
|
* @param projectUri Absolute path of the project, including .sqlproj
|
||||||
* @param path Path of the script, including .sql, relative to the .sqlproj
|
* @param path Path of the file, including extension, relative to the .sqlproj
|
||||||
*/
|
*/
|
||||||
public async excludeNoneItem(projectUri: string, path: string): Promise<azdata.ResultStatus> {
|
public async excludeNoneItem(projectUri: string, path: string): Promise<azdata.ResultStatus> {
|
||||||
const params: contracts.SqlProjectScriptParams = { projectUri: projectUri, path: path };
|
const params: contracts.SqlProjectScriptParams = { projectUri: projectUri, path: path };
|
||||||
@@ -455,7 +455,7 @@ export class SqlProjectsService extends BaseService implements mssql.ISqlProject
|
|||||||
* Move a SQL object script in a project
|
* Move a SQL object script in a project
|
||||||
* @param projectUri Absolute path of the project, including .sqlproj
|
* @param projectUri Absolute path of the project, including .sqlproj
|
||||||
* @param destinationPath Destination path of the file or folder, relative to the .sqlproj
|
* @param destinationPath Destination path of the file or folder, relative to the .sqlproj
|
||||||
* @param path Path of the script, including .sql, relative to the .sqlproj
|
* @param path Path of the file, including extension, relative to the .sqlproj
|
||||||
*/
|
*/
|
||||||
public async moveNoneItem(projectUri: string, destinationPath: string, path: string): Promise<azdata.ResultStatus> {
|
public async moveNoneItem(projectUri: string, destinationPath: string, path: string): Promise<azdata.ResultStatus> {
|
||||||
const params: contracts.MoveItemParams = { projectUri: projectUri, destinationPath: destinationPath, path: path };
|
const params: contracts.MoveItemParams = { projectUri: projectUri, destinationPath: destinationPath, path: path };
|
||||||
|
|||||||
12
extensions/sql-database-projects/src/common/typeHelper.ts
Normal file
12
extensions/sql-database-projects/src/common/typeHelper.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import * as mssql from 'mssql';
|
||||||
|
import * as vscodeMssql from 'vscode-mssql';
|
||||||
|
|
||||||
|
export type ProjectType = mssql.ProjectType | vscodeMssql.ProjectType;
|
||||||
|
export type GetScriptsResult = mssql.GetScriptsResult | vscodeMssql.GetScriptsResult;
|
||||||
|
export type GetFoldersResult = mssql.GetFoldersResult | vscodeMssql.GetFoldersResult;
|
||||||
|
export type SystemDatabase = mssql.SystemDatabase | vscodeMssql.SystemDatabase;
|
||||||
@@ -16,6 +16,7 @@ import * as fse from 'fs-extra';
|
|||||||
import * as which from 'which';
|
import * as which from 'which';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import { ISqlProject, SqlTargetPlatform } from 'sqldbproj';
|
import { ISqlProject, SqlTargetPlatform } from 'sqldbproj';
|
||||||
|
import { SystemDatabase } from './typeHelper';
|
||||||
|
|
||||||
export interface ValidationResult {
|
export interface ValidationResult {
|
||||||
errorMessage: string;
|
errorMessage: string;
|
||||||
@@ -157,14 +158,22 @@ export function convertSlashesForSqlProj(filePath: string): string {
|
|||||||
* @param systemDb
|
* @param systemDb
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function systemDatabaseToString(systemDb: mssql.SystemDatabase): string {
|
export function systemDatabaseToString(systemDb: SystemDatabase): string {
|
||||||
if (systemDb === mssql.SystemDatabase.Master) {
|
if (systemDb === mssql.SystemDatabase.Master || systemDb === vscodeMssql.SystemDatabase.Master) {
|
||||||
return constants.master;
|
return constants.master;
|
||||||
} else {
|
} else {
|
||||||
return constants.msdb;
|
return constants.msdb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSystemDatabase(name: string): SystemDatabase {
|
||||||
|
if (getAzdataApi()) {
|
||||||
|
return name === constants.master ? mssql.SystemDatabase.Master : mssql.SystemDatabase.MSDB;
|
||||||
|
} else {
|
||||||
|
return name === constants.master ? vscodeMssql.SystemDatabase.Master : vscodeMssql.SystemDatabase.MSDB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read SQLCMD variables from xmlDoc and return them
|
* Read SQLCMD variables from xmlDoc and return them
|
||||||
* @param xmlDoc xml doc to read SQLCMD variables from. Format must be the same that sqlproj and publish profiles use
|
* @param xmlDoc xml doc to read SQLCMD variables from. Format must be the same that sqlproj and publish profiles use
|
||||||
@@ -315,15 +324,14 @@ export async function getSchemaCompareService(): Promise<ISchemaCompareService>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSqlProjectsService(): Promise<mssql.ISqlProjectsService> {
|
export async function getSqlProjectsService(): Promise<ISqlProjectsService> {
|
||||||
if (getAzdataApi()) {
|
if (getAzdataApi()) {
|
||||||
const ext = vscode.extensions.getExtension(mssql.extension.name) as vscode.Extension<mssql.IExtension>;
|
const ext = vscode.extensions.getExtension(mssql.extension.name) as vscode.Extension<mssql.IExtension>;
|
||||||
const api = await ext.activate();
|
const api = await ext.activate();
|
||||||
return api.sqlProjects;
|
return api.sqlProjects;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(constants.errorNotSupportedInVsCode('SqlProjectService'));
|
const api = await getVscodeMssqlApi();
|
||||||
// const api = await getVscodeMssqlApi();
|
return api.sqlProjects;
|
||||||
// return api.sqlProjects;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,9 +202,8 @@ export class ProjectsController {
|
|||||||
const projectStyle = creationParams.sdkStyle ? mssql.ProjectType.SdkStyle : mssql.ProjectType.LegacyStyle;
|
const projectStyle = creationParams.sdkStyle ? mssql.ProjectType.SdkStyle : mssql.ProjectType.LegacyStyle;
|
||||||
await (sqlProjectsService as mssql.ISqlProjectsService).createProject(newProjFilePath, projectStyle, targetPlatform);
|
await (sqlProjectsService as mssql.ISqlProjectsService).createProject(newProjFilePath, projectStyle, targetPlatform);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(constants.errorNotSupportedInVsCode('createProject'));
|
const projectStyle = creationParams.sdkStyle ? mssqlVscode.ProjectType.SdkStyle : mssqlVscode.ProjectType.LegacyStyle;
|
||||||
//const projectStyle = creationParams.sdkStyle ? mssqlVscode.ProjectType.SdkStyle : mssqlVscode.ProjectType.LegacyStyle;
|
await (sqlProjectsService as mssqlVscode.ISqlProjectsService).createProject(newProjFilePath, projectStyle, targetPlatform);
|
||||||
//await (sqlProjectsService as mssqlVscode.ISqlProjectsService).createProject(newProjFilePath, projectStyle, targetPlatform);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.addTemplateFiles(newProjFilePath, creationParams.projectTypeId);
|
await this.addTemplateFiles(newProjFilePath, creationParams.projectTypeId);
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import { IconPathHelper } from '../common/iconHelper';
|
|||||||
import { ISystemDatabaseReferenceSettings, IDacpacReferenceSettings, IProjectReferenceSettings, INugetPackageReferenceSettings } from '../models/IDatabaseReferenceSettings';
|
import { ISystemDatabaseReferenceSettings, IDacpacReferenceSettings, IProjectReferenceSettings, INugetPackageReferenceSettings } from '../models/IDatabaseReferenceSettings';
|
||||||
import { Deferred } from '../common/promise';
|
import { Deferred } from '../common/promise';
|
||||||
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
||||||
import { ProjectType, SystemDatabase } from 'mssql';
|
|
||||||
import { DbServerValues, ensureSetOrDefined, populateResultWithVars } from './utils';
|
import { DbServerValues, ensureSetOrDefined, populateResultWithVars } from './utils';
|
||||||
|
import { ProjectType } from 'mssql';
|
||||||
|
|
||||||
export enum ReferenceType {
|
export enum ReferenceType {
|
||||||
project,
|
project,
|
||||||
@@ -160,7 +160,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
if (this.currentReferenceType === ReferenceType.systemDb) {
|
if (this.currentReferenceType === ReferenceType.systemDb) {
|
||||||
const systemDbRef: ISystemDatabaseReferenceSettings = {
|
const systemDbRef: ISystemDatabaseReferenceSettings = {
|
||||||
databaseVariableLiteralValue: <string>this.databaseNameTextbox?.value,
|
databaseVariableLiteralValue: <string>this.databaseNameTextbox?.value,
|
||||||
systemDb: getSystemDatabase(<string>this.systemDatabaseDropdown?.value),
|
systemDb: utils.getSystemDatabase(<string>this.systemDatabaseDropdown?.value),
|
||||||
suppressMissingDependenciesErrors: <boolean>this.suppressMissingDependenciesErrorsCheckbox?.checked
|
suppressMissingDependenciesErrors: <boolean>this.suppressMissingDependenciesErrorsCheckbox?.checked
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -734,10 +734,6 @@ export function getSystemDbOptions(project: Project): string[] {
|
|||||||
return [constants.master, constants.msdb];
|
return [constants.master, constants.msdb];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSystemDatabase(name: string): SystemDatabase {
|
|
||||||
return name === constants.master ? SystemDatabase.Master : SystemDatabase.MSDB;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function promptDacpacLocation(): Promise<vscode.Uri[] | undefined> {
|
export async function promptDacpacLocation(): Promise<vscode.Uri[] | undefined> {
|
||||||
return await vscode.window.showOpenDialog(
|
return await vscode.window.showOpenDialog(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
import path = require('path');
|
import path = require('path');
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as constants from '../common/constants';
|
import * as constants from '../common/constants';
|
||||||
import { getSqlProjectsInWorkspace, validateSqlCmdVariableName } from '../common/utils';
|
import { getSqlProjectsInWorkspace, getSystemDatabase, validateSqlCmdVariableName } from '../common/utils';
|
||||||
import { DbServerValues, populateResultWithVars } from './utils';
|
import { DbServerValues, populateResultWithVars } from './utils';
|
||||||
import { AddDatabaseReferenceSettings } from '../controllers/projectController';
|
import { AddDatabaseReferenceSettings } from '../controllers/projectController';
|
||||||
import { IDacpacReferenceSettings, IProjectReferenceSettings, ISystemDatabaseReferenceSettings } from '../models/IDatabaseReferenceSettings';
|
import { IDacpacReferenceSettings, IProjectReferenceSettings, ISystemDatabaseReferenceSettings } from '../models/IDatabaseReferenceSettings';
|
||||||
import { Project } from '../models/project';
|
import { Project } from '../models/project';
|
||||||
import { getSystemDatabase, getSystemDbOptions, promptDacpacLocation } from './addDatabaseReferenceDialog';
|
import { getSystemDbOptions, promptDacpacLocation } from './addDatabaseReferenceDialog';
|
||||||
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { SystemDatabase } from 'mssql';
|
|
||||||
import { Uri } from 'vscode';
|
import { Uri } from 'vscode';
|
||||||
|
import { SystemDatabase } from '../common/typeHelper';
|
||||||
|
|
||||||
export interface IDatabaseReferenceSettings {
|
export interface IDatabaseReferenceSettings {
|
||||||
databaseVariableLiteralValue?: string;
|
databaseVariableLiteralValue?: string;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import * as utils from '../common/utils';
|
|||||||
import type * as azdataType from 'azdata';
|
import type * as azdataType from 'azdata';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as mssql from 'mssql';
|
import * as mssql from 'mssql';
|
||||||
|
import * as vscodeMssql from 'vscode-mssql';
|
||||||
|
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import { Uri, window } from 'vscode';
|
import { Uri, window } from 'vscode';
|
||||||
@@ -20,7 +21,8 @@ import { DacpacReferenceProjectEntry, FileProjectEntry, NugetPackageReferencePro
|
|||||||
import { ResultStatus } from 'azdata';
|
import { ResultStatus } from 'azdata';
|
||||||
import { BaseProjectTreeItem } from './tree/baseTreeItem';
|
import { BaseProjectTreeItem } from './tree/baseTreeItem';
|
||||||
import { NoneNode, PostDeployNode, PreDeployNode, PublishProfileNode, SqlObjectFileNode } from './tree/fileFolderTreeItem';
|
import { NoneNode, PostDeployNode, PreDeployNode, PublishProfileNode, SqlObjectFileNode } from './tree/fileFolderTreeItem';
|
||||||
import { GetFoldersResult, GetScriptsResult, ProjectType, SystemDatabase } from 'mssql';
|
import { ProjectType, GetScriptsResult, GetFoldersResult } from '../common/typeHelper';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the configuration based on the Configuration property in the sqlproj
|
* Represents the configuration based on the Configuration property in the sqlproj
|
||||||
@@ -35,7 +37,7 @@ enum Configuration {
|
|||||||
* Class representing a Project, and providing functions for operating on it
|
* Class representing a Project, and providing functions for operating on it
|
||||||
*/
|
*/
|
||||||
export class Project implements ISqlProject {
|
export class Project implements ISqlProject {
|
||||||
private sqlProjService!: mssql.ISqlProjectsService;
|
private sqlProjService!: utils.ISqlProjectsService;
|
||||||
|
|
||||||
private _projectFilePath: string;
|
private _projectFilePath: string;
|
||||||
private _projectFileName: string;
|
private _projectFileName: string;
|
||||||
@@ -48,7 +50,7 @@ export class Project implements ISqlProject {
|
|||||||
private _preDeployScripts: FileProjectEntry[] = [];
|
private _preDeployScripts: FileProjectEntry[] = [];
|
||||||
private _postDeployScripts: FileProjectEntry[] = [];
|
private _postDeployScripts: FileProjectEntry[] = [];
|
||||||
private _noneDeployScripts: FileProjectEntry[] = [];
|
private _noneDeployScripts: FileProjectEntry[] = [];
|
||||||
private _sqlProjStyle: ProjectType = ProjectType.SdkStyle;
|
private _sqlProjStyle: ProjectType;
|
||||||
private _isCrossPlatformCompatible: boolean = false;
|
private _isCrossPlatformCompatible: boolean = false;
|
||||||
private _outputPath: string = '';
|
private _outputPath: string = '';
|
||||||
private _configuration: Configuration = Configuration.Debug;
|
private _configuration: Configuration = Configuration.Debug;
|
||||||
@@ -118,7 +120,11 @@ export class Project implements ISqlProject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get sqlProjStyleName(): string {
|
public get sqlProjStyleName(): string {
|
||||||
return this.sqlProjStyle === ProjectType.SdkStyle ? 'SdkStyle' : 'LegacyStyle';
|
if (utils.getAzdataApi()) {
|
||||||
|
return this.sqlProjStyle === mssql.ProjectType.SdkStyle ? 'SdkStyle' : 'LegacyStyle';
|
||||||
|
} else {
|
||||||
|
return this.sqlProjStyle === vscodeMssql.ProjectType.SdkStyle ? 'SdkStyle' : 'LegacyStyle';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public get isCrossPlatformCompatible(): boolean {
|
public get isCrossPlatformCompatible(): boolean {
|
||||||
@@ -142,6 +148,12 @@ export class Project implements ISqlProject {
|
|||||||
constructor(projectFilePath: string) {
|
constructor(projectFilePath: string) {
|
||||||
this._projectFilePath = projectFilePath;
|
this._projectFilePath = projectFilePath;
|
||||||
this._projectFileName = path.basename(projectFilePath, '.sqlproj');
|
this._projectFileName = path.basename(projectFilePath, '.sqlproj');
|
||||||
|
if (utils.getAzdataApi()) {
|
||||||
|
this._sqlProjStyle = mssql.ProjectType.SdkStyle;
|
||||||
|
} else {
|
||||||
|
this._sqlProjStyle = vscodeMssql.ProjectType.SdkStyle
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -228,7 +240,14 @@ export class Project implements ISqlProject {
|
|||||||
//#region Reader helpers
|
//#region Reader helpers
|
||||||
|
|
||||||
private async readProjectProperties(): Promise<void> {
|
private async readProjectProperties(): Promise<void> {
|
||||||
const result = await this.sqlProjService.getProjectProperties(this.projectFilePath);
|
let sqlProjService;
|
||||||
|
if (utils.getAzdataApi()) {
|
||||||
|
sqlProjService = this.sqlProjService as mssql.ISqlProjectsService;
|
||||||
|
} else {
|
||||||
|
sqlProjService = this.sqlProjService as vscodeMssql.ISqlProjectsService;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await sqlProjService.getProjectProperties(this.projectFilePath);
|
||||||
this.throwIfFailed(result);
|
this.throwIfFailed(result);
|
||||||
|
|
||||||
this._projectGuid = result.projectGuid;
|
this._projectGuid = result.projectGuid;
|
||||||
@@ -367,7 +386,14 @@ export class Project implements ISqlProject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async readNoneItems(): Promise<void> {
|
private async readNoneItems(): Promise<void> {
|
||||||
var result: GetScriptsResult = await this.sqlProjService.getNoneItems(this.projectFilePath);
|
let sqlProjService;
|
||||||
|
if (utils.getAzdataApi()) {
|
||||||
|
sqlProjService = (await utils.getSqlProjectsService()) as mssql.ISqlProjectsService;
|
||||||
|
} else {
|
||||||
|
sqlProjService = (await utils.getSqlProjectsService()) as vscodeMssql.ISqlProjectsService;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result: GetScriptsResult = await sqlProjService.getNoneItems(this.projectFilePath);
|
||||||
this.throwIfFailed(result);
|
this.throwIfFailed(result);
|
||||||
|
|
||||||
const noneItemEntries: FileProjectEntry[] = [];
|
const noneItemEntries: FileProjectEntry[] = [];
|
||||||
@@ -423,8 +449,14 @@ export class Project implements ISqlProject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const systemDbReference of databaseReferencesResult.systemDatabaseReferences) {
|
for (const systemDbReference of databaseReferencesResult.systemDatabaseReferences) {
|
||||||
|
let systemDb;
|
||||||
|
if (utils.getAzdataApi()) {
|
||||||
|
systemDb = systemDbReference.systemDb === mssql.SystemDatabase.Master ? constants.master : constants.msdb;
|
||||||
|
} else {
|
||||||
|
systemDb = systemDbReference.systemDb === vscodeMssql.SystemDatabase.Master ? constants.master : constants.msdb;
|
||||||
|
}
|
||||||
this._databaseReferences.push(new SystemDatabaseReferenceProjectEntry(
|
this._databaseReferences.push(new SystemDatabaseReferenceProjectEntry(
|
||||||
systemDbReference.systemDb === SystemDatabase.Master ? constants.master : constants.msdb,
|
systemDb,
|
||||||
systemDbReference.databaseVariableLiteralName,
|
systemDbReference.databaseVariableLiteralName,
|
||||||
systemDbReference.suppressMissingDependencies));
|
systemDbReference.suppressMissingDependencies));
|
||||||
}
|
}
|
||||||
@@ -769,8 +801,18 @@ export class Project implements ISqlProject {
|
|||||||
throw new Error(constants.databaseReferenceAlreadyExists);
|
throw new Error(constants.databaseReferenceAlreadyExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
const systemDb = <unknown>settings.systemDb as SystemDatabase;
|
let systemDb;
|
||||||
const result = await this.sqlProjService.addSystemDatabaseReference(this.projectFilePath, systemDb, settings.suppressMissingDependenciesErrors, settings.databaseVariableLiteralValue);
|
let result;
|
||||||
|
let sqlProjService;
|
||||||
|
if (utils.getAzdataApi()) {
|
||||||
|
systemDb = <unknown>settings.systemDb as mssql.SystemDatabase;
|
||||||
|
sqlProjService = this.sqlProjService as mssql.ISqlProjectsService;
|
||||||
|
result = await sqlProjService.addSystemDatabaseReference(this.projectFilePath, systemDb, settings.suppressMissingDependenciesErrors, settings.databaseVariableLiteralValue);
|
||||||
|
} else {
|
||||||
|
systemDb = <unknown>settings.systemDb as vscodeMssql.SystemDatabase;
|
||||||
|
sqlProjService = this.sqlProjService as vscodeMssql.ISqlProjectsService;
|
||||||
|
result = await sqlProjService.addSystemDatabaseReference(this.projectFilePath, systemDb, settings.suppressMissingDependenciesErrors, settings.databaseVariableLiteralValue);
|
||||||
|
}
|
||||||
|
|
||||||
if (!result.success && result.errorMessage) {
|
if (!result.success && result.errorMessage) {
|
||||||
throw new Error(constants.errorAddingDatabaseReference(utils.systemDatabaseToString(settings.systemDb), result.errorMessage));
|
throw new Error(constants.errorAddingDatabaseReference(utils.systemDatabaseToString(settings.systemDb), result.errorMessage));
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import { BaseProjectTreeItem } from './baseTreeItem';
|
|||||||
import * as fileTree from './fileFolderTreeItem';
|
import * as fileTree from './fileFolderTreeItem';
|
||||||
import { Project } from '../project';
|
import { Project } from '../project';
|
||||||
import * as utils from '../../common/utils';
|
import * as utils from '../../common/utils';
|
||||||
|
import * as mssql from 'mssql';
|
||||||
|
import * as vscodeMssql from 'vscode-mssql';
|
||||||
import { DatabaseReferencesTreeItem } from './databaseReferencesTreeItem';
|
import { DatabaseReferencesTreeItem } from './databaseReferencesTreeItem';
|
||||||
import { DatabaseProjectItemType, RelativeOuterPath, ExternalStreamingJob, sqlprojExtension, CollapseProjectNodesKey, errorPrefix } from '../../common/constants';
|
import { DatabaseProjectItemType, RelativeOuterPath, ExternalStreamingJob, sqlprojExtension, CollapseProjectNodesKey, errorPrefix } from '../../common/constants';
|
||||||
import { IconPathHelper } from '../../common/iconHelper';
|
import { IconPathHelper } from '../../common/iconHelper';
|
||||||
@@ -16,7 +18,6 @@ import { FileProjectEntry } from '../projectEntry';
|
|||||||
import { EntryType } from 'sqldbproj';
|
import { EntryType } from 'sqldbproj';
|
||||||
import { DBProjectConfigurationKey } from '../../tools/netcoreTool';
|
import { DBProjectConfigurationKey } from '../../tools/netcoreTool';
|
||||||
import { SqlCmdVariablesTreeItem } from './sqlcmdVariableTreeItem';
|
import { SqlCmdVariablesTreeItem } from './sqlcmdVariableTreeItem';
|
||||||
import { ProjectType } from 'mssql';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TreeNode root that represents an entire project
|
* TreeNode root that represents an entire project
|
||||||
@@ -60,7 +61,13 @@ export class ProjectRootTreeItem extends BaseProjectTreeItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get type(): DatabaseProjectItemType {
|
public get type(): DatabaseProjectItemType {
|
||||||
return this.project.sqlProjStyle === ProjectType.SdkStyle ? DatabaseProjectItemType.project : DatabaseProjectItemType.legacyProject;
|
let projectType;
|
||||||
|
if (utils.getAzdataApi()) {
|
||||||
|
projectType = this.project.sqlProjStyle === mssql.ProjectType.SdkStyle ? DatabaseProjectItemType.project : DatabaseProjectItemType.legacyProject;
|
||||||
|
} else {
|
||||||
|
projectType = this.project.sqlProjStyle === vscodeMssql.ProjectType.SdkStyle ? DatabaseProjectItemType.project : DatabaseProjectItemType.legacyProject;
|
||||||
|
}
|
||||||
|
return projectType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ import should = require('should');
|
|||||||
import { AssertionError } from 'assert';
|
import { AssertionError } from 'assert';
|
||||||
import { Project } from '../models/project';
|
import { Project } from '../models/project';
|
||||||
import { Uri } from 'vscode';
|
import { Uri } from 'vscode';
|
||||||
import { exists, getSqlProjectsService } from '../common/utils';
|
import { exists, getAzdataApi, getSqlProjectsService } from '../common/utils';
|
||||||
import { ProjectType } from 'mssql';
|
import * as mssql from 'mssql';
|
||||||
|
import * as vscodeMssql from 'vscode-mssql';
|
||||||
|
|
||||||
export async function shouldThrowSpecificError(block: Function, expectedMessage: string, details?: string) {
|
export async function shouldThrowSpecificError(block: Function, expectedMessage: string, details?: string) {
|
||||||
let succeeded = false;
|
let succeeded = false;
|
||||||
@@ -33,7 +34,7 @@ export async function shouldThrowSpecificError(block: Function, expectedMessage:
|
|||||||
|
|
||||||
export async function createTestSqlProject(test: Mocha.Runnable | undefined): Promise<Project> {
|
export async function createTestSqlProject(test: Mocha.Runnable | undefined): Promise<Project> {
|
||||||
const projPath = await getTestProjectPath(test);
|
const projPath = await getTestProjectPath(test);
|
||||||
await (await getSqlProjectsService()).createProject(projPath, ProjectType.SdkStyle);
|
await (await getSqlProjectsService() as mssql.ISqlProjectsService).createProject(projPath, mssql.ProjectType.SdkStyle);
|
||||||
return await Project.openProject(projPath);
|
return await Project.openProject(projPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ import * as extractZip from 'extract-zip';
|
|||||||
import * as constants from '../common/constants';
|
import * as constants from '../common/constants';
|
||||||
import { HttpClient } from '../common/httpClient';
|
import { HttpClient } from '../common/httpClient';
|
||||||
import { DBProjectConfigurationKey } from './netcoreTool';
|
import { DBProjectConfigurationKey } from './netcoreTool';
|
||||||
import { ProjectType } from 'mssql';
|
import { ProjectType } from '../common/typeHelper';
|
||||||
|
import * as mssql from 'mssql';
|
||||||
|
import * as vscodeMssql from 'vscode-mssql';
|
||||||
|
|
||||||
const buildDirectory = 'BuildDirectory';
|
const buildDirectory = 'BuildDirectory';
|
||||||
const sdkName = 'Microsoft.Build.Sql';
|
const sdkName = 'Microsoft.Build.Sql';
|
||||||
@@ -136,11 +138,19 @@ export class BuildHelper {
|
|||||||
// Right now SystemDacpacsLocation and NETCoreTargetsPath get set to the same thing, but separating them out for if we move
|
// Right now SystemDacpacsLocation and NETCoreTargetsPath get set to the same thing, but separating them out for if we move
|
||||||
// the system dacpacs somewhere else and also so that the variable name makes more sense if building from the commandline,
|
// the system dacpacs somewhere else and also so that the variable name makes more sense if building from the commandline,
|
||||||
// since SDK style projects don't to specify the targets path, just where the system dacpacs are
|
// since SDK style projects don't to specify the targets path, just where the system dacpacs are
|
||||||
if (sqlProjStyle === ProjectType.SdkStyle) {
|
if (utils.getAzdataApi()) {
|
||||||
|
if (sqlProjStyle === mssql.ProjectType.SdkStyle) {
|
||||||
|
return ` build ${projectPath} /p:NetCoreBuild=true /p:SystemDacpacsLocation=${buildDirPath}`;
|
||||||
|
} else {
|
||||||
|
return ` build ${projectPath} /p:NetCoreBuild=true /p:NETCoreTargetsPath=${buildDirPath} /p:SystemDacpacsLocation=${buildDirPath}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (sqlProjStyle === vscodeMssql.ProjectType.SdkStyle) {
|
||||||
return ` build ${projectPath} /p:NetCoreBuild=true /p:SystemDacpacsLocation=${buildDirPath}`;
|
return ` build ${projectPath} /p:NetCoreBuild=true /p:SystemDacpacsLocation=${buildDirPath}`;
|
||||||
} else {
|
} else {
|
||||||
return ` build ${projectPath} /p:NetCoreBuild=true /p:NETCoreTargetsPath=${buildDirPath} /p:SystemDacpacsLocation=${buildDirPath}`;
|
return ` build ${projectPath} /p:NetCoreBuild=true /p:NETCoreTargetsPath=${buildDirPath} /p:SystemDacpacsLocation=${buildDirPath}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user