如何添加“便携式”到电子构建器.exe文件名?

发布于 2025-02-04 11:06:28 字数 712 浏览 2 评论 0 原文

这是我的软件包。JSON构建数据:

"build": {
    "appId": "name.desktop",
    "productName": "name",
    "beforePack": "electron/beforePack.js",
    "extraResources": [
      {
        "from": "bin/${os}",
        "to": "bin",
        "filter": [
          "**/*"
        ]
      }
    ],
    "files": [
      "build/**/*",
      "electron/**/*",
      "package.json"
    ],
    "extends": null,
    "mac": {
      "target": "dmg",
      "type": "distribution"
    },
    "win": {
      "target": [
        "portable", 
        "nsis"
      ]
    },
    "linux": {
      "target": "AppImage"
    }
  }

我希望将“ Portable”添加到Windows Portable文件名中,以便.exe为“名称1.0.0 Portable.exe”,而不是“名称1.0.0.0.exe”

This is my package.json build data:

"build": {
    "appId": "name.desktop",
    "productName": "name",
    "beforePack": "electron/beforePack.js",
    "extraResources": [
      {
        "from": "bin/${os}",
        "to": "bin",
        "filter": [
          "**/*"
        ]
      }
    ],
    "files": [
      "build/**/*",
      "electron/**/*",
      "package.json"
    ],
    "extends": null,
    "mac": {
      "target": "dmg",
      "type": "distribution"
    },
    "win": {
      "target": [
        "portable", 
        "nsis"
      ]
    },
    "linux": {
      "target": "AppImage"
    }
  }

I'm looking to add "portable" to the windows portable file name, so that the .exe is "name 1.0.0 portable.exe" instead of "name 1.0.0.exe"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦醒灬来后我 2025-02-11 11:06:28

可以通过使用 package.json 文件中的每个相关级别明确定义生成的文件名,通过使用“ artifactname” 属性。

这在常见配置 - 电子构建器页:

如果需要,也可以设置每个平台(顶级密钥Mac,Linux和Win)的选项。

这间接地指文件宏 文件模式的部分 - 电子构建器页面。

在您的具体情况下,您必须将以下“ artifactname” 属性添加到 package.json.json 在Windows版本级别:

  "artifactName": "${name} ${version} portable.${ext}",

IE::

"build": {
    "appId": "name.desktop",
    "productName": "name",
    "beforePack": "electron/beforePack.js",
    "extraResources": [
      {
        "from": "bin/${os}",
        "to": "bin",
        "filter": [
          "**/*"
        ]
      }
    ],
    "files": [
      "build/**/*",
      "electron/**/*",
      "package.json"
    ],
    "extends": null,
    "mac": {
      "target": "dmg",
      "type": "distribution"
    },
    "win": {
      "artifactName": "${name} ${version} portable.${ext}",
      "target": [
        "portable", 
        "nsis"
      ]
    },
    "linux": {
      "target": "AppImage"
    }
  }

It is possible to explicitely define the generated file names at each relevant level in the package.json file by making use of an "artifactName" property.

This is documented in the Overridable per Platform Options section of the Common Configuration - electron-builder page:

Following options can be set also per platform (top-level keys mac, linux and win) if need.

  • artifactName String | “undefined” - The artifact file name template. Defaults to ${productName}-${version}.${ext} (some target can have other defaults, see corresponding options).

which indirectly refers to the File Macros section of the File Patterns - electron-builder page.

In your specific case, you'll have to add the following "artifactName" property to your package.json file at the Windows version level:

  "artifactName": "${name} ${version} portable.${ext}",

i.e.:

"build": {
    "appId": "name.desktop",
    "productName": "name",
    "beforePack": "electron/beforePack.js",
    "extraResources": [
      {
        "from": "bin/${os}",
        "to": "bin",
        "filter": [
          "**/*"
        ]
      }
    ],
    "files": [
      "build/**/*",
      "electron/**/*",
      "package.json"
    ],
    "extends": null,
    "mac": {
      "target": "dmg",
      "type": "distribution"
    },
    "win": {
      "artifactName": "${name} ${version} portable.${ext}",
      "target": [
        "portable", 
        "nsis"
      ]
    },
    "linux": {
      "target": "AppImage"
    }
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文