mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Read publish profile using DacFX (#16110)
* Read publish profile using DacFX in VS Code * Fixes * complete promise on hide * comment
This commit is contained in:
@@ -26,7 +26,7 @@ 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';
|
||||
import { readPublishProfile } from '../models/publishProfile/publishProfile';
|
||||
import { AddDatabaseReferenceDialog } from '../dialogs/addDatabaseReferenceDialog';
|
||||
import { ISystemDatabaseReferenceSettings, IDacpacReferenceSettings, IProjectReferenceSettings } from '../models/IDatabaseReferenceSettings';
|
||||
import { DatabaseReferenceTreeItem } from '../models/tree/databaseReferencesTreeItem';
|
||||
@@ -39,8 +39,6 @@ import { launchPublishDatabaseQuickpick } from '../dialogs/publishDatabaseQuickp
|
||||
|
||||
const maxTableLength = 10;
|
||||
|
||||
export type IDacFxService = mssql.IDacFxService | mssqlVscode.IDacFxService;
|
||||
|
||||
/**
|
||||
* Controller for managing lifecycle of projects
|
||||
*/
|
||||
@@ -242,9 +240,9 @@ export class ProjectsController {
|
||||
if (utils.getAzdataApi()) {
|
||||
let publishDatabaseDialog = this.getPublishDialog(project);
|
||||
|
||||
publishDatabaseDialog.publish = async (proj, prof) => await this.publishProjectCallback(proj, prof);
|
||||
publishDatabaseDialog.generateScript = async (proj, prof) => await this.publishProjectCallback(proj, prof);
|
||||
publishDatabaseDialog.readPublishProfile = async (profileUri) => await this.readPublishProfileCallback(profileUri);
|
||||
publishDatabaseDialog.publish = async (proj, prof) => this.publishProjectCallback(proj, prof);
|
||||
publishDatabaseDialog.generateScript = async (proj, prof) => this.publishProjectCallback(proj, prof);
|
||||
publishDatabaseDialog.readPublishProfile = async (profileUri) => readPublishProfile(profileUri);
|
||||
|
||||
publishDatabaseDialog.openDialog();
|
||||
|
||||
@@ -279,7 +277,7 @@ export class ProjectsController {
|
||||
const tempPath = path.join(os.tmpdir(), `${path.parse(dacpacPath).name}_${new Date().getTime()}${constants.sqlprojExtension}`);
|
||||
await fs.copyFile(dacpacPath, tempPath);
|
||||
|
||||
const dacFxService = await this.getDaxFxService();
|
||||
const dacFxService = await utils.getDacFxService();
|
||||
|
||||
let result: mssql.DacFxResult;
|
||||
telemetryProps.profileUsed = (settings.profileUsed ?? false).toString();
|
||||
@@ -349,17 +347,6 @@ export class ProjectsController {
|
||||
return result;
|
||||
}
|
||||
|
||||
public async readPublishProfileCallback(profileUri: vscode.Uri): Promise<PublishProfile> {
|
||||
try {
|
||||
const dacFxService = await this.getDaxFxService();
|
||||
const profile = await load(profileUri, dacFxService);
|
||||
return profile;
|
||||
} catch (e) {
|
||||
vscode.window.showErrorMessage(constants.profileReadError);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public async schemaCompare(treeNode: dataworkspace.WorkspaceTreeItem): Promise<void> {
|
||||
try {
|
||||
// check if schema compare extension is installed
|
||||
@@ -740,7 +727,7 @@ export class ProjectsController {
|
||||
|
||||
const streamingJobDefinition: string = (await fs.readFile(node.element.fileSystemUri.fsPath)).toString();
|
||||
|
||||
const dacFxService = await this.getDaxFxService();
|
||||
const dacFxService = await utils.getDacFxService();
|
||||
const actionStartTime = new Date().getTime();
|
||||
|
||||
const result: mssql.ValidateStreamingJobResult = await dacFxService.validateStreamingJob(dacpacPath, streamingJobDefinition);
|
||||
@@ -831,21 +818,6 @@ export class ProjectsController {
|
||||
}
|
||||
}
|
||||
|
||||
public async getDaxFxService(): Promise<IDacFxService> {
|
||||
if (utils.getAzdataApi()) {
|
||||
const ext: vscode.Extension<mssql.IExtension> = vscode.extensions.getExtension(mssql.extension.name)!;
|
||||
const extensionApi = await ext.activate();
|
||||
return extensionApi.dacFx;
|
||||
} else {
|
||||
const ext: vscode.Extension<mssqlVscode.IExtension> = vscode.extensions.getExtension(mssql.extension.name)!;
|
||||
const extensionApi = await ext.activate();
|
||||
return extensionApi.dacFx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async promptForNewObjectName(itemType: templates.ProjectScriptType, _project: Project, folderPath: string, fileExtension?: string): Promise<string | undefined> {
|
||||
const suggestedName = itemType.friendlyName.replace(/\s+/g, '');
|
||||
let counter: number = 0;
|
||||
|
||||
Reference in New Issue
Block a user