From 4fa2b50077893a3f3347fe968d6d54c6b0cafe50 Mon Sep 17 00:00:00 2001 From: Kim Santiago <31145923+kisantia@users.noreply.github.com> Date: Tue, 11 Jan 2022 15:05:58 -0800 Subject: [PATCH] load name and options from publish profile for vscode publish quickpick (#18044) * load name and options from publihs profile for vscode publish quickpick * fix when a publish profile doesn't have the target db name * update condition * simplify --- .../src/dialogs/publishDatabaseQuickpick.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts b/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts index a4d09fe7c4..b9dbd9d0c1 100644 --- a/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts +++ b/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts @@ -109,13 +109,17 @@ export async function getPublishDatabaseSettings(project: Project, promptForConn // Add Create New at the top now so it'll show second to top below the suggested name of the current project dbQuickpicks.unshift({ label: `$(add) ${constants.createNew}`, isCreateNew: true }); - // Ensure the project name is an option, either adding it if it doesn't already exist or moving it to the top if it does - const projectNameIndex = dbs.findIndex(db => db === project.projectFileName); + // if a publish profile was loaded and had a database name, use that instead of the project file name + const dbName = publishProfile?.databaseName || project.projectFileName; + + // Ensure the project name or name specified in the publish profile is an option, either adding it if it + // doesn't already exist or moving it to the top if it does + const projectNameIndex = dbs.findIndex(db => db === dbName); if (projectNameIndex === -1) { - dbQuickpicks.unshift({ label: project.projectFileName, description: constants.newText }); + dbQuickpicks.unshift({ label: dbName, description: constants.newText }); } else { dbQuickpicks.splice(projectNameIndex, 1); - dbQuickpicks.unshift({ label: project.projectFileName }); + dbQuickpicks.unshift({ label: dbName }); } let databaseName: string | undefined = undefined; @@ -196,7 +200,7 @@ export async function getPublishDatabaseSettings(project: Project, promptForConn serverName: connectionProfile?.server || '', connectionUri: connectionUri || '', sqlCmdVariables: sqlCmdVariables, - deploymentOptions: await getDefaultPublishDeploymentOptions(project), + deploymentOptions: publishProfile?.options ?? await getDefaultPublishDeploymentOptions(project), profileUsed: !!publishProfile }; return settings;