Fix for #10779 to clean build to work in SSDT post ADS build (#10882)

* Add clean target

* include in test baselines

* adding one more test
This commit is contained in:
Udeesha Gautam
2020-06-12 12:11:18 -07:00
committed by GitHub
parent a7110d8916
commit 60c0ac6bd7
10 changed files with 220 additions and 10 deletions

View File

@@ -78,6 +78,7 @@ export class Project {
await fs.copyFile(this.projectFilePath, this.projectFilePath + '_backup');
await this.updateImportToSupportRoundTrip();
await this.updatePackageReferenceInProjFile();
await this.updateAfterCleanTargetInProjFile();
}
private async updateImportToSupportRoundTrip(): Promise<void> {
@@ -99,6 +100,30 @@ export class Project {
await this.updateImportedTargetsToProjFile(constants.NetCoreCondition, constants.NetCoreTargets, undefined);
}
private async updateAfterCleanTargetInProjFile(): Promise<void> {
// Search if clean target already present, update it
for (let i = 0; i < this.projFileXmlDoc.documentElement.getElementsByTagName(constants.Target).length; i++) {
const afterCleanNode = this.projFileXmlDoc.documentElement.getElementsByTagName(constants.Target)[i];
const name = afterCleanNode.getAttribute(constants.Name);
if (name === constants.AfterCleanTarget) {
return await this.createCleanFileNode(afterCleanNode);
}
}
// If clean target not found, create new
const afterCleanNode = this.projFileXmlDoc.createElement(constants.Target);
afterCleanNode.setAttribute(constants.Name, constants.AfterCleanTarget);
this.projFileXmlDoc.documentElement.appendChild(afterCleanNode);
await this.createCleanFileNode(afterCleanNode);
}
private async createCleanFileNode(parentNode: any): Promise<void> {
const deleteFileNode = this.projFileXmlDoc.createElement(constants.Delete);
deleteFileNode.setAttribute(constants.Files, constants.ProjJsonToClean);
parentNode.appendChild(deleteFileNode);
await this.serializeToProjFile(this.projFileXmlDoc);
}
/**
* Adds a folder to the project, and saves the project file
* @param relativeFolderPath Relative path of the folder