mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 01:25:37 -05:00
remove default VS properties when converting legacy to SDK-style sql project (#19255)
This commit is contained in:
@@ -661,8 +661,42 @@ export class Project implements ISqlProject {
|
||||
}
|
||||
}
|
||||
|
||||
const parent = importsToRemove[0]?.parentNode;
|
||||
importsToRemove.forEach(i => { parent?.removeChild(i); });
|
||||
const importsParent = importsToRemove[0]?.parentNode;
|
||||
importsToRemove.forEach(i => {
|
||||
importsParent?.removeChild(i);
|
||||
});
|
||||
|
||||
// remove VisualStudio properties
|
||||
const vsPropsToRemove = [];
|
||||
for (let i = 0; i < this.projFileXmlDoc!.documentElement.getElementsByTagName(constants.VisualStudioVersion).length; i++) {
|
||||
const visualStudioVersionNode = this.projFileXmlDoc!.documentElement.getElementsByTagName(constants.VisualStudioVersion)[i];
|
||||
const conditionAttributeVal = visualStudioVersionNode.getAttribute(constants.Condition);
|
||||
|
||||
if (conditionAttributeVal === constants.VSVersionCondition || conditionAttributeVal === constants.SsdtExistsCondition) {
|
||||
vsPropsToRemove.push(visualStudioVersionNode);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.projFileXmlDoc!.documentElement.getElementsByTagName(constants.SSDTExists).length; i++) {
|
||||
const ssdtExistsNode = this.projFileXmlDoc!.documentElement.getElementsByTagName(constants.SSDTExists)[i];
|
||||
const conditionAttributeVal = ssdtExistsNode.getAttribute(constants.Condition);
|
||||
|
||||
if (conditionAttributeVal === constants.targetsExistsCondition) {
|
||||
vsPropsToRemove.push(ssdtExistsNode);
|
||||
}
|
||||
}
|
||||
|
||||
const vsPropsParent = vsPropsToRemove[0]?.parentNode;
|
||||
vsPropsToRemove.forEach(i => {
|
||||
vsPropsParent?.removeChild(i);
|
||||
|
||||
// Remove the parent PropertyGroup if there aren't any other nodes. Only count element nodes, not text nodes
|
||||
const otherChildren = Array.from(vsPropsParent!.childNodes).filter((c: ChildNode) => c.childNodes);
|
||||
|
||||
if (otherChildren.length === 0) {
|
||||
vsPropsParent!.parentNode?.removeChild(vsPropsParent!);
|
||||
}
|
||||
});
|
||||
|
||||
// add SDK node
|
||||
const sdkNode = this.projFileXmlDoc!.createElement(constants.Sdk);
|
||||
|
||||
Reference in New Issue
Block a user