鸿蒙多Product配置及打包--添加多个证书配置,打正式包,内测包,限设备安装包等;一键编译打包所有product

鸿蒙多Product配置及打包--添加多个证书配置,打正式包,内测包,限设备安装包等;一键编译打包所有product

一.为不同的product产物配置签名信息

【配置正确的证书,密钥和相关信息!!】

https://developer.huawei.com/consumer/cn/doc/best-practices/bpta-multi-target#section13944162214508


二.build-profile.json5配置

【1.signingConfigs正确添加配置 】

【2.products正确添加配置】

【3.applyToProducts正确添加配置】

复制代码
{
  "app": {
    // 1. 签名配置:定义正式、测试、内测的签名信息
    "signingConfigs": [
      {
        "name": "release", // 正式发布签名
        "type": "HarmonyOS",
        "material": {
          "storeFile": "./cert/release.p12", // 正式私钥文件
          "storePassword": "release_pwd", // 私钥库密码
          "keyAlias": "release_key", // 私钥别名
          "keyPassword": "release_key_pwd", // 私钥密码
          "signAlg": "SHA256withECDSA", // 签名算法
          "profile": "./profile/release.p7b", // 正式Profile
          "certpath": "./cert/release.cer" // 正式证书
        }
      },
      {
        "name": "test", // 测试发布签名
        "type": "HarmonyOS",
        "material": {
          "storeFile": "./cert/test.p12",
          "storePassword": "test_pwd",
          "keyAlias": "test_key",
          "keyPassword": "test_key_pwd",
          "signAlg": "SHA256withECDSA",
          "profile": "./profile/test.p7b", // 测试Profile
          "certpath": "./cert/test.cer"
        }
      },
      {
        "name": "internal", // 限设备内测签名
        "type": "HarmonyOS",
        "material": {
          "storeFile": "./cert/internal.p12",
          "storePassword": "internal_pwd",
          "keyAlias": "internal_key",
          "keyPassword": "internal_key_pwd",
          "signAlg": "SHA256withECDSA",
          "profile": "./profile/internal_test.p7b", // 内部测试Profile(关联设备UDID)
          "certpath": "./cert/internal.cer"
        }
      }
    ],

    // 2. 构建产品:定义不同环境的打包目标
    "products": [
      {
        "name": "release", // 正式发布产品
        "signingConfig": "release", // 关联正式签名
        "compatibleSdkVersion": "5.0.0(12)",
        "runtimeOS": "HarmonyOS",
        "buildOption": {
          "strictMode": { "caseSensitiveCheck": true }
        },
        // 正式环境资源目录(如配置、图片)
        "resourceGroups": [{ "name": "config", "src": "src/main/resources/release" }]
      },
      {
        "name": "test", // 测试发布产品
        "signingConfig": "test", // 关联测试签名
        "compatibleSdkVersion": "5.0.0(12)",
        "runtimeOS": "HarmonyOS",
        "buildOption": {
          "strictMode": { "caseSensitiveCheck": true }
        },
        // 测试环境资源目录
        "resourceGroups": [{ "name": "config", "src": "src/main/resources/test" }]
      },
      {
        "name": "internal", // 限设备内测产品
        "signingConfig": "internal", // 关联内测签名
        "compatibleSdkVersion": "5.0.0(12)",
        "runtimeOS": "HarmonyOS",
        "buildOption": {
          "strictMode": { "caseSensitiveCheck": true }
        },
        // 内测环境资源目录
        "resourceGroups": [{ "name": "config", "src": "src/main/resources/internal" }]
      }
    ],

    // 3. 构建模式:定义debug/release模式(可选)
    "buildModeSet": [
      { "name": "debug" }, // 调试模式(默认)
      { "name": "release" } // 发布模式
    ]
  },

  // 模块配置(如entry模块)
  "modules": [
    {
      "name": "entry",
      "srcPath": "./entry",
      "targets": [
        {
          "name": "default",
          // 关联产品:该target适用于所有产品
          "applyToProducts": ["release", "test", "internal"]
        }
      ]
    }
  ]
}

三.多Product打包:一键编译打包所有product

https://developer.huawei.com/consumer/cn/doc/architecture-guides/educate-v1_1-ts_137-0000002396830386

复制代码
hvigorw -p product=default -p buildMode=release assembleApp; 
hvigorw -p product=default1 -p buildMode=release assembleApp; 
hvigorw -p product=default2 -p buildMode=release assembleApp;
相关推荐
键盘鼓手苏苏10 小时前
Flutter for OpenHarmony:csslib 强力 CSS 样式解析器,构建自定义渲染引擎的基石(Dart 官方解析库) 深度解析与鸿蒙适配指南
css·flutter·harmonyos
阿林来了18 小时前
Flutter三方库适配OpenHarmony【flutter_speech】— 持续语音识别与长录音
flutter·语音识别·harmonyos
松叶似针19 小时前
Flutter三方库适配OpenHarmony【secure_application】— 与 HarmonyOS 安全能力的深度集成
安全·flutter·harmonyos
星空222319 小时前
【HarmonyOS】day39:React Native实战项目+智能文本省略Hook开发
react native·华为·harmonyos
星空222321 小时前
【HarmonyOS】day40:React Native实战项目+自定义Hooks开发指南
react native·华为·harmonyos
Swift社区1 天前
鸿蒙 PC 架构的终点:工作流
华为·harmonyos
左手厨刀右手茼蒿2 天前
Flutter for OpenHarmony:dart_console 打造炫酷命令行界面,绘制表格、控制光标与进度条(CLI 交互库) 深度解析与鸿蒙适配指南
flutter·交互·harmonyos·绘制
加农炮手Jinx2 天前
Flutter for OpenHarmony 实战:疯狂头像 App(三)— 复合动画与交互反馈 — 让 UI 跃动起来
flutter·ui·交互·harmonyos·鸿蒙
王码码20352 天前
lutter for OpenHarmony 实战之基础组件:第六十二篇 SystemChannels — 探秘 Flutter 与系统交互的捷径
flutter·microsoft·交互·harmonyos
pvIaUtLZ2 天前
Comsol超表面折射率传感器。 电磁诱导透明EIT和典型连续体中的束缚态BIC
华为