Skip to content

Commit 078b79e

Browse files
authored
Merge pull request #1130 from stevedlawrence/reproducible-content-types-xml
Make the [Content_Types].xml file deterministic
2 parents 864fa4a + 3cfa05e commit 078b79e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/package.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,8 +1605,16 @@ export async function toContentTypes(files: IFile[]): Promise<string> {
16051605
contentTypes.push(`<Default Extension="${extension}" ContentType="${contentType}"/>`);
16061606
}
16071607

1608+
// The files array passed into this function has non-deterministic order
1609+
// depending on filesystem directory traversal. This leads to the order of
1610+
// the "Default" elements changing from build to build, which prevents
1611+
// reproducible vsix files. To fix this, this sorts the contentTypes array
1612+
// to ensure they are listed in the same order regardless of the order of
1613+
// the files array.
1614+
const sortedContentTypes = contentTypes.sort();
1615+
16081616
return `<?xml version="1.0" encoding="utf-8"?>
1609-
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">${contentTypes.join('')}</Types>
1617+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">${sortedContentTypes.join('')}</Types>
16101618
`;
16111619
}
16121620

0 commit comments

Comments
 (0)