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:
Kim Santiago
2021-11-22 11:50:06 -10:00
committed by GitHub
parent ef4dab072a
commit a79c61ff4e
3 changed files with 41 additions and 18 deletions

View File

@@ -16,7 +16,12 @@
<ItemGroup>
<Build Include="..\other\folder1\file*.sql" />
<Build Remove="..\other\folder1\file1.sql" />
<Build Include="..\other\folder2\file2.sql" />
<Build Remove="..\other\folder2\**" />
<Build Remove="folder1\*.sql" />
<Build Include="folder1\file2.sql" />
<Build Remove="folder2\file3.sql" />
<Build Include="folder2\*.sql" />
<Build Remove="file1.sql" />
</ItemGroup>
<ItemGroup>

View File

@@ -929,21 +929,40 @@ describe('Project: sdk style project content operations', function (): void {
const project: Project = await Project.openProject(projFilePath);
should(project.files.filter(f => f.type === EntryType.File).length).equal(6);
should(project.files.filter(f => f.type === EntryType.File).length).equal(7);
// make sure all the correct files from the globbing patterns were included and removed are evaluated in order
// make sure all the correct files from the globbing patterns were included and excluded
// <Build Include="..\other\folder1\file*.sql" />
// <Build Remove="..\other\folder1\file1.sql" />
// expected: ..\other\folder1\file1.sql is not included
should(project.files.filter(f => f.relativePath === '..\\other\\folder1\\file1.sql').length).equal(0);
should(project.files.filter(f => f.relativePath === '..\\other\\folder1\\file2.sql').length).equal(1);
// <Build Include="..\other\folder2\file2.sql" />
// <Build Remove="..\other\folder2\**" />
// expected: ..\other\folder2\file2.sql is not included
should(project.files.filter(f => f.relativePath === '..\\other\\folder2\\file1.sql').length).equal(0);
should(project.files.filter(f => f.relativePath === '..\\other\\folder2\\file2.sql').length).equal(0);
// <Build Remove="folder1\*.sql" />
// <Build Include="folder1\file2.sql" />
// expected: folder1\file2.sql is included
should(project.files.filter(f => f.relativePath === 'folder1\\file1.sql').length).equal(0);
should(project.files.filter(f => f.relativePath === 'folder1\\file2.sql').length).equal(0);
should(project.files.filter(f => f.relativePath === 'folder1\\file2.sql').length).equal(1);
should(project.files.filter(f => f.relativePath === 'folder1\\file3.sql').length).equal(0);
should(project.files.filter(f => f.relativePath === 'folder1\\file4.sql').length).equal(0);
should(project.files.filter(f => f.relativePath === 'folder1\\file5.sql').length).equal(0);
// <Build Remove="folder2\file3.sql" />
// <Build Include="folder2\*.sql" />
// expected: folder2\file3.sql is included
should(project.files.filter(f => f.relativePath === 'folder2\\file1.sql').length).equal(1);
should(project.files.filter(f => f.relativePath === 'folder2\\file2.sql').length).equal(1);
should(project.files.filter(f => f.relativePath === 'folder2\\file3.sql').length).equal(1);
should(project.files.filter(f => f.relativePath === 'folder2\\file4.sql').length).equal(1);
should(project.files.filter(f => f.relativePath === 'folder2\\file5.sql').length).equal(1);
// <Build Remove="file1.sql" />
should(project.files.filter(f => f.relativePath === 'file1.sql').length).equal(0);
});