diff --git a/extensions/sql-database-projects/src/controllers/projectController.ts b/extensions/sql-database-projects/src/controllers/projectController.ts index 11096442f0..dd87ed2a23 100644 --- a/extensions/sql-database-projects/src/controllers/projectController.ts +++ b/extensions/sql-database-projects/src/controllers/projectController.ts @@ -1128,31 +1128,27 @@ export class ProjectsController { public async createProjectFromDatabaseCallback(model: ImportDataModel) { try { + const newProjFolderUri = model.filePath; + + const newProjFilePath = await this.createNewProject({ + newProjName: model.projName, + folderUri: vscode.Uri.file(newProjFolderUri), + projectTypeId: constants.emptySqlDatabaseProjectTypeId + }); + + model.filePath = path.dirname(newProjFilePath); + this.setFilePath(model); + + const project = await Project.openProject(newProjFilePath); + await this.createProjectFromDatabaseApiCall(model); // Call ExtractAPI in DacFx Service + let fileFolderList: vscode.Uri[] = model.extractTarget === mssql.ExtractTarget.file ? [vscode.Uri.file(model.filePath)] : await this.generateList(model.filePath); // Create a list of all the files and directories to be added to project + + await project.addToProject(fileFolderList); // Add generated file structure to the project + + // add project to workspace const workspaceApi = utils.getDataWorkspaceExtensionApi(); - - const validateWorkspace = await workspaceApi.validateWorkspace(); - if (validateWorkspace) { - const newProjFolderUri = model.filePath; - - const newProjFilePath = await this.createNewProject({ - newProjName: model.projName, - folderUri: vscode.Uri.file(newProjFolderUri), - projectTypeId: constants.emptySqlDatabaseProjectTypeId - }); - - model.filePath = path.dirname(newProjFilePath); - this.setFilePath(model); - - const project = await Project.openProject(newProjFilePath); - await this.createProjectFromDatabaseApiCall(model); // Call ExtractAPI in DacFx Service - let fileFolderList: vscode.Uri[] = model.extractTarget === mssql.ExtractTarget.file ? [vscode.Uri.file(model.filePath)] : await this.generateList(model.filePath); // Create a list of all the files and directories to be added to project - - await project.addToProject(fileFolderList); // Add generated file structure to the project - - // add project to workspace - workspaceApi.showProjectsView(); - await workspaceApi.addProjectsToWorkspace([vscode.Uri.file(newProjFilePath)]); - } + workspaceApi.showProjectsView(); + await workspaceApi.addProjectsToWorkspace([vscode.Uri.file(newProjFilePath)]); } catch (err) { void vscode.window.showErrorMessage(utils.getErrorMessage(err)); } diff --git a/extensions/sql-database-projects/src/dialogs/createProjectFromDatabaseDialog.ts b/extensions/sql-database-projects/src/dialogs/createProjectFromDatabaseDialog.ts index 82a8b26081..03ed202dfe 100644 --- a/extensions/sql-database-projects/src/dialogs/createProjectFromDatabaseDialog.ts +++ b/extensions/sql-database-projects/src/dialogs/createProjectFromDatabaseDialog.ts @@ -372,9 +372,6 @@ export class CreateProjectFromDatabaseDialog { async validate(): Promise { try { - if (await getDataWorkspaceExtensionApi().validateWorkspace() === false) { - return false; - } // the selected location should be an existing directory const parentDirectoryExists = await exists(this.projectLocationTextBox!.value!); if (!parentDirectoryExists) { @@ -388,6 +385,11 @@ export class CreateProjectFromDatabaseDialog { this.showErrorMessage(constants.ProjectDirectoryAlreadyExistError(this.projectNameTextBox!.value!, this.projectLocationTextBox!.value!)); return false; } + + if (await getDataWorkspaceExtensionApi().validateWorkspace() === false) { + return false; + } + return true; } catch (err) { this.showErrorMessage(err?.message ? err.message : err);