mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 01:25:36 -05:00
load publish profile sqlcmd "value" tag and throw error if not loaded correctly (#11615)
* load publish profile sqlcmd "value" tag and throw error if not loaded correctly * moved the read profile function to utils
This commit is contained in:
@@ -13,7 +13,6 @@ import * as os from 'os';
|
||||
import { Uri } from 'vscode';
|
||||
import { promises as fs } from 'fs';
|
||||
import { DataSource } from './dataSources/dataSources';
|
||||
import { readSqlCmdVariables } from './publishProfile/publishProfile';
|
||||
|
||||
/**
|
||||
* Class representing a Project, and providing functions for operating on it
|
||||
@@ -81,7 +80,7 @@ export class Project {
|
||||
}
|
||||
|
||||
// find all SQLCMD variables to include
|
||||
this.sqlCmdVariables = readSqlCmdVariables(this.projFileXmlDoc);
|
||||
this.sqlCmdVariables = utils.readSqlCmdVariables(this.projFileXmlDoc);
|
||||
|
||||
// find all database references to include
|
||||
const references = this.projFileXmlDoc.documentElement.getElementsByTagName(constants.ArtifactReference);
|
||||
|
||||
@@ -41,7 +41,7 @@ export async function load(profileUri: Uri, dacfxService: mssql.IDacFxService):
|
||||
const optionsResult = await dacfxService.getOptionsFromProfile(profileUri.fsPath);
|
||||
|
||||
// get all SQLCMD variables to include from the profile
|
||||
const sqlCmdVariables = readSqlCmdVariables(profileXmlDoc);
|
||||
const sqlCmdVariables = utils.readSqlCmdVariables(profileXmlDoc);
|
||||
|
||||
return {
|
||||
databaseName: targetDbName,
|
||||
@@ -52,22 +52,6 @@ export async function load(profileUri: Uri, dacfxService: mssql.IDacFxService):
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export function readSqlCmdVariables(xmlDoc: any): Record<string, string> {
|
||||
let sqlCmdVariables: Record<string, string> = {};
|
||||
for (let i = 0; i < xmlDoc.documentElement.getElementsByTagName(constants.SqlCmdVariable)?.length; i++) {
|
||||
const sqlCmdVar = xmlDoc.documentElement.getElementsByTagName(constants.SqlCmdVariable)[i];
|
||||
const varName = sqlCmdVar.getAttribute(constants.Include);
|
||||
|
||||
const varValue = sqlCmdVar.getElementsByTagName(constants.DefaultValue)[0].childNodes[0].nodeValue;
|
||||
sqlCmdVariables[varName] = varValue;
|
||||
}
|
||||
|
||||
return sqlCmdVariables;
|
||||
}
|
||||
|
||||
async function readConnectionString(xmlDoc: any): Promise<{ connectionId: string, connectionString: string }> {
|
||||
let targetConnectionString: string = '';
|
||||
|
||||
Reference in New Issue
Block a user