Skip to content

Commit

Permalink
feat: add config options for setting MinVersion and `MaxVersionTest…
Browse files Browse the repository at this point in the history
…ed` fields in appx manifest (#8142)
  • Loading branch information
mmaietta authored Mar 20, 2024
1 parent 9f4b458 commit 8160363
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-lemons-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": minor
---

feat: add config options for setting `MinVersion` and `MaxVersionTested` fields in appx manifest
2 changes: 2 additions & 0 deletions docs/configuration/appx.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ All options are optional. All required for AppX configuration is inferred and co
<li><code id="AppXOptions-customExtensionsPath">customExtensionsPath</code> String - Relative path to custom extensions xml to be included in an <code>appmanifest.xml</code>.</li>
<li><code id="AppXOptions-showNameOnTiles">showNameOnTiles</code> = <code>false</code> Boolean - Whether to overlay the app’s name on top of tile images on the Start screen. Defaults to <code>false</code>. (<a href="https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-shownameontiles">https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-shownameontiles</a>) in the dependencies.</li>
<li><code id="AppXOptions-setBuildNumber">setBuildNumber</code> = <code>false</code> Boolean - Whether to set build number. See <a href="https://github.com/electron-userland/electron-builder/issues/3875">https://github.com/electron-userland/electron-builder/issues/3875</a></li>
<li><code id="AppXOptions-minVersion">minVersion</code> = <code>arch === Arch.arm64 ? &quot;10.0.16299.0&quot; : &quot;10.0.14316.0&quot;</code> String | “undefined” - Set the MinVersion field in the appx manifest.xml</li>
<li><code id="AppXOptions-maxVersionTested">maxVersionTested</code> = <code>arch === Arch.arm64 ? &quot;10.0.16299.0&quot; : &quot;10.0.14316.0&quot;</code> String | “undefined” - Set the <code>MaxVersionTested</code> field in the appx manifest.xml</li>
</ul>
<p>Inherited from <code>TargetSpecificOptions</code>:</p>
<ul>
Expand Down
16 changes: 16 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,22 @@
}
]
},
"maxVersionTested": {
"default": "arch === Arch.arm64 ? \"10.0.16299.0\" : \"10.0.14316.0\"",
"description": "Set the `MaxVersionTested` field in the appx manifest.xml",
"type": [
"null",
"string"
]
},
"minVersion": {
"default": "arch === Arch.arm64 ? \"10.0.16299.0\" : \"10.0.14316.0\"",
"description": "Set the MinVersion field in the appx manifest.xml",
"type": [
"null",
"string"
]
},
"publish": {
"anyOf": [
{
Expand Down
12 changes: 12 additions & 0 deletions packages/app-builder-lib/src/options/AppXOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ export interface AppXOptions extends TargetSpecificOptions {
*/
readonly setBuildNumber?: boolean

/**
* Set the MinVersion field in the appx manifest.xml
* @default arch === Arch.arm64 ? "10.0.16299.0" : "10.0.14316.0"
*/
readonly minVersion?: string | null

/**
* Set the `MaxVersionTested` field in the appx manifest.xml
* @default arch === Arch.arm64 ? "10.0.16299.0" : "10.0.14316.0"
*/
readonly maxVersionTested?: string | null

/** @private */
readonly makeappxArgs?: Array<string> | null
}
5 changes: 3 additions & 2 deletions packages/app-builder-lib/src/targets/AppxTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export default class AppXTarget extends Target {
const executable = `app\\${appInfo.productFilename}.exe`
const displayName = options.displayName || appInfo.productName
const extensions = await this.getExtensions(executable, displayName)
const archSpecificMinVersion = arch === Arch.arm64 ? "10.0.16299.0" : "10.0.14316.0"

const manifest = (await readFile(path.join(getTemplatePath("appx"), "appxmanifest.xml"), "utf8")).replace(/\${([a-zA-Z0-9]+)}/g, (match, p1): string => {
switch (p1) {
Expand Down Expand Up @@ -252,10 +253,10 @@ export default class AppXTarget extends Target {
return extensions

case "minVersion":
return arch === Arch.arm64 ? "10.0.16299.0" : "10.0.14316.0"
return options.minVersion || archSpecificMinVersion

case "maxVersionTested":
return arch === Arch.arm64 ? "10.0.16299.0" : "10.0.14316.0"
return options.maxVersionTested || options.minVersion || archSpecificMinVersion

default:
throw new Error(`Macro ${p1} is not defined`)
Expand Down
2 changes: 2 additions & 0 deletions test/src/windows/appxTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ it(
cscKeyPassword: "test",
appx: {
languages: ["de-DE", "ru-RU"],
minVersion: "10.0.16299.0",
maxVersionTested: "10.0.16299.0",
},
},
})
Expand Down

0 comments on commit 8160363

Please sign in to comment.