From 253f7774de7d72a5627b7ba507c0757e5f9a83c7 Mon Sep 17 00:00:00 2001 From: Kim Santiago <31145923+kisantia@users.noreply.github.com> Date: Thu, 1 Oct 2020 15:26:27 -0700 Subject: [PATCH] Fix can't find SQLCMD variable error (#12672) * remove sqlcmd variable deletion verification * check if sqlcmd variable exists first --- extensions/sql-database-projects/src/models/project.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/sql-database-projects/src/models/project.ts b/extensions/sql-database-projects/src/models/project.ts index 88b0e6907a..527174223c 100644 --- a/extensions/sql-database-projects/src/models/project.ts +++ b/extensions/sql-database-projects/src/models/project.ts @@ -679,7 +679,9 @@ export class Project { public addSqlCmdVariableToProjFile(entry: SqlCmdVariableProjectEntry): void { // Remove any entries with the same variable name. It'll be replaced with a new one - this.removeFromProjFile(entry); + if (Object.keys(this.sqlCmdVariables).includes(entry.variableName)) { + this.removeFromProjFile(entry); + } const sqlCmdVariableNode = this.projFileXmlDoc.createElement(constants.SqlCmdVariable); sqlCmdVariableNode.setAttribute(constants.Include, entry.variableName);