mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 17:22:42 -05:00
update add file/folder for msbuild sdk style projects (#17660)
* update add file for msbuild sdk style projects * also handle add folder * fix comment
This commit is contained in:
@@ -863,7 +863,7 @@ export class Project implements ISqlProject {
|
||||
return outputItemGroup;
|
||||
}
|
||||
|
||||
private addFileToProjFile(path: string, xmlTag: string, attributes?: Map<string, string>): void {
|
||||
private async addFileToProjFile(path: string, xmlTag: string, attributes?: Map<string, string>): Promise<void> {
|
||||
let itemGroup;
|
||||
|
||||
if (xmlTag === constants.PreDeploy || xmlTag === constants.PostDeploy) {
|
||||
@@ -876,6 +876,14 @@ export class Project implements ISqlProject {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const currentFiles = await this.readFilesInProject();
|
||||
|
||||
// don't need to add an entry if it's already included by a glob pattern
|
||||
// unless it has an attribute that needs to be added, like external streaming job which needs it so it can be determined if validation can run on it
|
||||
if (attributes?.size === 0 && currentFiles.find(f => f.relativePath === utils.convertSlashesForSqlProj(path))) {
|
||||
return;
|
||||
}
|
||||
|
||||
itemGroup = this.findOrCreateItemGroup(xmlTag);
|
||||
}
|
||||
|
||||
@@ -1202,7 +1210,7 @@ export class Project implements ISqlProject {
|
||||
private async addToProjFile(entry: ProjectEntry, xmlTag?: string, attributes?: Map<string, string>): Promise<void> {
|
||||
switch (entry.type) {
|
||||
case EntryType.File:
|
||||
this.addFileToProjFile((<FileProjectEntry>entry).relativePath, xmlTag ? xmlTag : constants.Build, attributes);
|
||||
await this.addFileToProjFile((<FileProjectEntry>entry).relativePath, xmlTag ? xmlTag : constants.Build, attributes);
|
||||
break;
|
||||
case EntryType.Folder:
|
||||
this.addFolderToProjFile((<FileProjectEntry>entry).relativePath);
|
||||
@@ -1351,6 +1359,11 @@ export class Project implements ISqlProject {
|
||||
// If folder doesn't exist, create it
|
||||
await fs.mkdir(absoluteFolderPath, { recursive: true });
|
||||
|
||||
// don't need to add the folder to the sqlproj if this is an msbuild sdk style project because globbing will get the folders
|
||||
if (this.isMsbuildSdkStyleProject) {
|
||||
return this.createFileProjectEntry(relativeFolderPath, EntryType.Folder);
|
||||
}
|
||||
|
||||
// Add project file entries for all folders in the path.
|
||||
// SSDT expects all folders to be explicitly listed in the project file, so we construct
|
||||
// folder paths for all intermediate folders and ensure they are present in the project as well.
|
||||
|
||||
Reference in New Issue
Block a user