mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-15 17:22:25 -05:00
Fix ordering of reading sqlproj Build Includes and Removes (#17712)
* evaluate includes and removes in order in sqlproj * fix after merge * fix comment * update comment
This commit is contained in:
@@ -172,16 +172,17 @@ export class Project implements ISqlProject {
|
||||
for (let ig = 0; ig < this.projFileXmlDoc!.documentElement.getElementsByTagName(constants.ItemGroup).length; ig++) {
|
||||
const itemGroup = this.projFileXmlDoc!.documentElement.getElementsByTagName(constants.ItemGroup)[ig];
|
||||
|
||||
// find all files to include that are specified in the project file
|
||||
// find all files to include that are specified to be included and removed (for sdk style projects) in the project file
|
||||
// the build elements are evaluated in the order they are in the sqlproj (same way sdk style csproj handles this)
|
||||
try {
|
||||
const buildElements = itemGroup.getElementsByTagName(constants.Build);
|
||||
|
||||
// <Build Include....>
|
||||
for (let b = 0; b < buildElements.length; b++) {
|
||||
const relativePath = buildElements[b].getAttribute(constants.Include)!;
|
||||
// <Build Include....>
|
||||
const includeRelativePath = buildElements[b].getAttribute(constants.Include)!;
|
||||
|
||||
if (relativePath) {
|
||||
const fullPath = path.join(utils.getPlatformSafeFileEntryPath(this.projectFolderPath), utils.getPlatformSafeFileEntryPath(relativePath));
|
||||
if (includeRelativePath) {
|
||||
const fullPath = path.join(utils.getPlatformSafeFileEntryPath(this.projectFolderPath), utils.getPlatformSafeFileEntryPath(includeRelativePath));
|
||||
|
||||
// sdk style projects can handle other globbing patterns like <Build Include="folder1\*.sql" /> and <Build Include="Production*.sql" />
|
||||
if (this._isSdkStyleProject && !(await utils.exists(fullPath))) {
|
||||
@@ -192,25 +193,23 @@ export class Project implements ISqlProject {
|
||||
filesSet.add(newFileRelativePath);
|
||||
});
|
||||
} else {
|
||||
filesSet.add(relativePath);
|
||||
filesSet.add(includeRelativePath);
|
||||
|
||||
// Right now only used for external streaming jobs
|
||||
const typeAttribute = buildElements[b].getAttribute(constants.Type)!;
|
||||
if (typeAttribute) {
|
||||
entriesWithType.push({ relativePath, typeAttribute });
|
||||
entriesWithType.push({ relativePath: includeRelativePath, typeAttribute: typeAttribute });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// <Build Remove....>
|
||||
// after all the files have been included, remove the ones specified in the sqlproj to remove
|
||||
if (this._isSdkStyleProject) {
|
||||
for (let b = 0; b < buildElements.length; b++) {
|
||||
const relativePath = buildElements[b].getAttribute(constants.Remove)!;
|
||||
// <Build Remove....>
|
||||
// remove files specified in the sqlproj to remove if this is an sdk style project
|
||||
if (this._isSdkStyleProject) {
|
||||
const removeRelativePath = buildElements[b].getAttribute(constants.Remove)!;
|
||||
|
||||
if (relativePath) {
|
||||
const fullPath = path.join(utils.getPlatformSafeFileEntryPath(this.projectFolderPath), utils.getPlatformSafeFileEntryPath(relativePath));
|
||||
if (removeRelativePath) {
|
||||
const fullPath = path.join(utils.getPlatformSafeFileEntryPath(this.projectFolderPath), utils.getPlatformSafeFileEntryPath(removeRelativePath));
|
||||
|
||||
const globRemoveFiles = await utils.globWithPattern(fullPath);
|
||||
globRemoveFiles.forEach(gf => {
|
||||
|
||||
Reference in New Issue
Block a user