Skip to content

Commit b16a890

Browse files
danielweckdevelar
authored andcommitted
feat(appx): added missing support for AppX fileAssociations (#4302)
1 parent 5692281 commit b16a890

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/app-builder-lib/src/targets/AppxTarget.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,16 @@ export default class AppXTarget extends Target {
251251
const uriSchemes = asArray(this.packager.config.protocols)
252252
.concat(asArray(this.packager.platformSpecificBuildOptions.protocols))
253253

254+
const fileAssociations = asArray(this.packager.config.fileAssociations)
255+
.concat(asArray(this.packager.platformSpecificBuildOptions.fileAssociations))
256+
254257
let isAddAutoLaunchExtension = this.options.addAutoLaunchExtension
255258
if (isAddAutoLaunchExtension === undefined) {
256259
const deps = this.packager.info.metadata.dependencies
257260
isAddAutoLaunchExtension = deps != null && deps["electron-winstore-auto-launch"] != null
258261
}
259262

260-
if (!isAddAutoLaunchExtension && uriSchemes.length === 0) {
263+
if (!isAddAutoLaunchExtension && uriSchemes.length === 0 && fileAssociations.length === 0) {
261264
return ""
262265
}
263266

@@ -281,6 +284,19 @@ export default class AppXTarget extends Target {
281284
}
282285
}
283286

287+
for (const fileAssociation of fileAssociations) {
288+
for (const ext of asArray(fileAssociation.ext)) {
289+
extensions += `
290+
<uap:Extension Category="windows.fileTypeAssociation">
291+
<uap:FileTypeAssociation Name="${ext}">
292+
<uap:SupportedFileTypes>
293+
<uap:FileType>.${ext}</uap:FileType>
294+
</uap:SupportedFileTypes>
295+
</uap:FileTypeAssociation>
296+
</uap:Extension>`
297+
}
298+
}
299+
284300
extensions += "</Extensions>"
285301
return extensions
286302
}

0 commit comments

Comments
 (0)