mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 09:35:36 -05:00
Load connection from publish profile (#11263)
* initial changes for reading connection from profile * connection string can now be read from publish.xml * fix build errors and update test * move publish profile tests to their own file * cleanup * update message * fix string * remove apiWrapper
This commit is contained in:
@@ -11,7 +11,6 @@ import * as path from 'path';
|
||||
import * as utils from '../common/utils';
|
||||
import * as UUID from 'vscode-languageclient/lib/utils/uuid';
|
||||
import * as templates from '../templates/templates';
|
||||
import * as xmldom from 'xmldom';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
@@ -20,12 +19,13 @@ import { PublishDatabaseDialog } from '../dialogs/publishDatabaseDialog';
|
||||
import { Project, DatabaseReferenceLocation, SystemDatabase, TargetPlatform, ProjectEntry, reservedProjectFolders } from '../models/project';
|
||||
import { SqlDatabaseProjectTreeViewProvider } from './databaseProjectTreeViewProvider';
|
||||
import { FolderNode, FileNode } from '../models/tree/fileFolderTreeItem';
|
||||
import { IPublishSettings, IGenerateScriptSettings, PublishProfile } from '../models/IPublishSettings';
|
||||
import { IPublishSettings, IGenerateScriptSettings } from '../models/IPublishSettings';
|
||||
import { BaseProjectTreeItem } from '../models/tree/baseTreeItem';
|
||||
import { ProjectRootTreeItem } from '../models/tree/projectTreeItem';
|
||||
import { ImportDataModel } from '../models/api/import';
|
||||
import { NetCoreTool, DotNetCommandOptions } from '../tools/netcoreTool';
|
||||
import { BuildHelper } from '../tools/buildHelper';
|
||||
import { PublishProfile, load } from '../models/publishProfile/publishProfile';
|
||||
|
||||
/**
|
||||
* Controller for managing project lifecycle
|
||||
@@ -199,7 +199,7 @@ export class ProjectsController {
|
||||
|
||||
publishDatabaseDialog.publish = async (proj, prof) => await this.executionCallback(proj, prof);
|
||||
publishDatabaseDialog.generateScript = async (proj, prof) => await this.executionCallback(proj, prof);
|
||||
publishDatabaseDialog.readPublishProfile = async (profileUri) => await this.readPublishProfile(profileUri);
|
||||
publishDatabaseDialog.readPublishProfile = async (profileUri) => await this.readPublishProfileCallback(profileUri);
|
||||
|
||||
publishDatabaseDialog.openDialog();
|
||||
|
||||
@@ -227,25 +227,9 @@ export class ProjectsController {
|
||||
}
|
||||
}
|
||||
|
||||
public async readPublishProfile(profileUri: vscode.Uri): Promise<PublishProfile> {
|
||||
const profileText = await fs.readFile(profileUri.fsPath);
|
||||
const profileXmlDoc = new xmldom.DOMParser().parseFromString(profileText.toString());
|
||||
|
||||
// read target database name
|
||||
let targetDbName: string = '';
|
||||
let targetDatabaseNameCount = profileXmlDoc.documentElement.getElementsByTagName(constants.targetDatabaseName).length;
|
||||
if (targetDatabaseNameCount > 0) {
|
||||
// if there is more than one TargetDatabaseName nodes, SSDT uses the name in the last one so we'll do the same here
|
||||
targetDbName = profileXmlDoc.documentElement.getElementsByTagName(constants.targetDatabaseName)[targetDatabaseNameCount - 1].textContent;
|
||||
}
|
||||
|
||||
// get all SQLCMD variables to include from the profile
|
||||
let sqlCmdVariables = utils.readSqlCmdVariables(profileXmlDoc);
|
||||
|
||||
return {
|
||||
databaseName: targetDbName,
|
||||
sqlCmdVariables: sqlCmdVariables
|
||||
};
|
||||
public async readPublishProfileCallback(profileUri: vscode.Uri): Promise<PublishProfile> {
|
||||
const profile = await load(profileUri);
|
||||
return profile;
|
||||
}
|
||||
|
||||
public async schemaCompare(treeNode: BaseProjectTreeItem): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user