diff --git a/extensions/sql-database-projects/package.json b/extensions/sql-database-projects/package.json index a8d05518db..0fa6ea62f7 100644 --- a/extensions/sql-database-projects/package.json +++ b/extensions/sql-database-projects/package.json @@ -480,7 +480,7 @@ "vscode-nls": "^4.1.2", "which": "^2.0.2", "xml-formatter": "2.1.0", - "xmldom": "^0.6.0" + "@xmldom/xmldom": "^0.8.2" }, "devDependencies": { "@types/fs-extra": "^5.0.0", @@ -488,7 +488,6 @@ "@types/sinon": "^9.0.4", "@types/which": "^2.0.1", "@types/xml-formatter": "^1.1.0", - "@types/xmldom": "^0.1.29", "mocha": "^7.1.1", "mocha-junit-reporter": "^1.17.0", "mocha-multi-reporters": "^1.1.7", diff --git a/extensions/sql-database-projects/src/models/project.ts b/extensions/sql-database-projects/src/models/project.ts index f5cc126765..9589b6173a 100644 --- a/extensions/sql-database-projects/src/models/project.ts +++ b/extensions/sql-database-projects/src/models/project.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as path from 'path'; -import * as xmldom from 'xmldom'; +import * as xmldom from '@xmldom/xmldom'; import * as constants from '../common/constants'; import * as utils from '../common/utils'; import * as xmlFormat from 'xml-formatter'; @@ -1583,12 +1583,15 @@ export class Project implements ISqlProject { const suppressMissingDependenciesErrorNode = currentNode.getElementsByTagName(constants.SuppressMissingDependenciesErrors); const suppressMissingDependences = suppressMissingDependenciesErrorNode[0].childNodes[0].nodeValue === constants.True; - // remove this node - this.projFileXmlDoc!.documentElement.removeChild(currentNode); - - // delete ItemGroup if there aren't any other children - if (this.projFileXmlDoc!.documentElement.getElementsByTagName(constants.ArtifactReference).length === 0) { + // TODO Two issues here : + // 1. If there are multiple ItemGroups with ArtifactReference items then we won't clean up until all items are removed + // 2. If the ItemGroup has other non-ArtifactReference items in it then those will be deleted + // Right now we assume that this ItemGroup is not manually edited so it's safe to ignore these + if (this.projFileXmlDoc!.documentElement.getElementsByTagName(constants.ArtifactReference).length === 1) { + // delete entire ItemGroup if there aren't any other children this.projFileXmlDoc!.documentElement.removeChild(currentNode.parentNode!); + } else { + this.projFileXmlDoc!.documentElement.removeChild(currentNode); } // remove from database references because it'll get added again later diff --git a/extensions/sql-database-projects/src/models/publishProfile/publishProfile.ts b/extensions/sql-database-projects/src/models/publishProfile/publishProfile.ts index 881bb1cefc..e2dd074e01 100644 --- a/extensions/sql-database-projects/src/models/publishProfile/publishProfile.ts +++ b/extensions/sql-database-projects/src/models/publishProfile/publishProfile.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as xmldom from 'xmldom'; +import * as xmldom from '@xmldom/xmldom'; import * as constants from '../../common/constants'; import * as utils from '../../common/utils'; import * as mssql from 'mssql'; diff --git a/extensions/sql-database-projects/yarn.lock b/extensions/sql-database-projects/yarn.lock index 412528a83e..6dfba31d0a 100644 --- a/extensions/sql-database-projects/yarn.lock +++ b/extensions/sql-database-projects/yarn.lock @@ -332,10 +332,10 @@ resolved "https://registry.yarnpkg.com/@types/xml-formatter/-/xml-formatter-1.2.0.tgz#f1a98b2f99f8021304d58d7cc89f73e6515da450" integrity sha512-hTJriFFYEHKMQXP3/dTxL9f1LbqZ/f6cJ/T77znGGFtet/9+9IqHWV2j4TH3OR/HRZ2ucv/c6in0tdmYwGHdYg== -"@types/xmldom@^0.1.29": - version "0.1.31" - resolved "https://registry.yarnpkg.com/@types/xmldom/-/xmldom-0.1.31.tgz#519b647cfc66debf82cdf50e49763c8fdee553d6" - integrity sha512-bVy7s0nvaR5D1mT1a8ZkByHWNOGb6Vn4yi5TWhEdmyKlAG+08SA7Md6+jH+tYmMLueAwNeWvHHpeKrr6S4c4BA== +"@xmldom/xmldom@^0.8.2": + version "0.8.2" + resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.8.2.tgz#b695ff674e8216efa632a3d36ad51ae9843380c0" + integrity sha512-+R0juSseERyoPvnBQ/cZih6bpF7IpCXlWbHRoCRzYzqpz6gWHOgf8o4MOEf6KBVuOyqU+gCNLkCWVIJAro8XyQ== ansi-colors@3.2.3: version "3.2.3" @@ -1891,11 +1891,6 @@ xml@^1.0.0: resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU= -xmldom@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.6.0.tgz#43a96ecb8beece991cef382c08397d82d4d0c46f" - integrity sha512-iAcin401y58LckRZ0TkI4k0VSM1Qg0KGSc3i8rU+xrxe19A/BN1zHyVSJY7uoutVlaTSzYyk/v5AmkewAP7jtg== - y18n@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf"