fix: standardize build output path to outputs/default/bundles/signed

This commit is contained in:
cheliangzhao
2026-02-11 11:46:38 +08:00
parent 01da810dfa
commit d1d89b7225
3 changed files with 25 additions and 37 deletions

View File

@@ -35,20 +35,16 @@ Complete workflow for building, cleaning, packaging, and installing HarmonyOS ap
# Build complete app (incremental) # Build complete app (incremental)
hvigorw assembleApp --mode project -p product=default -p buildMode=release --no-daemon hvigorw assembleApp --mode project -p product=default -p buildMode=release --no-daemon
# Install to device (check actual output path in your project) # Install to device
# Use a random directory name to avoid conflicts with previous installations # Use a random directory name to avoid conflicts with previous installations
INSTALL_DIR="/data/local/tmp/install_$(date +%s)" INSTALL_DIR="/data/local/tmp/install_$(date +%s)"
hdc -t <UDID> shell "mkdir -p $INSTALL_DIR" hdc -t <UDID> shell "mkdir -p $INSTALL_DIR"
hdc -t <UDID> file send <output_path>/signed $INSTALL_DIR hdc -t <UDID> file send outputs/default/bundles/signed $INSTALL_DIR
hdc -t <UDID> shell "bm install -p $INSTALL_DIR/signed" hdc -t <UDID> shell "bm install -p $INSTALL_DIR/signed"
hdc -t <UDID> shell "rm -rf $INSTALL_DIR" hdc -t <UDID> shell "rm -rf $INSTALL_DIR"
``` ```
**Note:** Build output path varies by project. Common paths: **Note:** Build output path is `outputs/default/bundles/signed/`.
- `outputs/default/signed/`
- `outputs/project/bundles/signed/`
Check your project's actual output after build.
## Workflows ## Workflows
@@ -61,12 +57,12 @@ Delegate to subagent with the following steps:
1. Clean: `hvigorw clean --no-daemon` 1. Clean: `hvigorw clean --no-daemon`
2. Install dependencies: `ohpm install --all` 2. Install dependencies: `ohpm install --all`
3. Build: `hvigorw assembleApp --mode project -p product=default -p buildMode=release --no-daemon` 3. Build: `hvigorw assembleApp --mode project -p product=default -p buildMode=release --no-daemon`
4. Find build output (check `outputs/default/signed/` or `outputs/project/bundles/signed/`) 4. Build output is at `outputs/default/bundles/signed/`
5. Deploy to device: 5. Deploy to device:
```bash ```bash
INSTALL_DIR="/data/local/tmp/install_$(date +%s)" INSTALL_DIR="/data/local/tmp/install_$(date +%s)"
hdc -t <UDID> shell "mkdir -p $INSTALL_DIR" hdc -t <UDID> shell "mkdir -p $INSTALL_DIR"
hdc -t <UDID> file send <output_path>/signed $INSTALL_DIR hdc -t <UDID> file send outputs/default/bundles/signed $INSTALL_DIR
hdc -t <UDID> shell "bm install -p $INSTALL_DIR/signed" hdc -t <UDID> shell "bm install -p $INSTALL_DIR/signed"
hdc -t <UDID> shell "rm -rf $INSTALL_DIR" hdc -t <UDID> shell "rm -rf $INSTALL_DIR"
``` ```
@@ -82,7 +78,7 @@ Delegate to subagent with the following steps:
```bash ```bash
INSTALL_DIR="/data/local/tmp/install_$(date +%s)" INSTALL_DIR="/data/local/tmp/install_$(date +%s)"
hdc -t <UDID> shell "mkdir -p $INSTALL_DIR" hdc -t <UDID> shell "mkdir -p $INSTALL_DIR"
hdc -t <UDID> file send <output_path>/signed $INSTALL_DIR hdc -t <UDID> file send outputs/default/bundles/signed $INSTALL_DIR
hdc -t <UDID> shell "bm install -p $INSTALL_DIR/signed" hdc -t <UDID> shell "bm install -p $INSTALL_DIR/signed"
hdc -t <UDID> shell "rm -rf $INSTALL_DIR" hdc -t <UDID> shell "rm -rf $INSTALL_DIR"
``` ```
@@ -205,20 +201,14 @@ hvigorw assembleApp # Build complete APP bundle
## Build Outputs ## Build Outputs
Build output path varies by project configuration. Common patterns: Build output path: `outputs/default/bundles/signed/`
``` ```
outputs/ outputs/default/bundles/signed/
├── default/signed/ # Pattern 1
│ ├── entry-default-signed.hap
│ └── *.hsp
└── project/bundles/signed/ # Pattern 2
├── entry-default-signed.hap ├── entry-default-signed.hap
└── *.hsp └── *.hsp
``` ```
**Tip:** After build, check the actual output directory in your project.
### Module Types ### Module Types
| Type | Extension | Description | | Type | Extension | Description |
@@ -261,7 +251,7 @@ INSTALL_DIR="/data/local/tmp/install_$(date +%s)"
hdc -t <UDID> shell "mkdir -p $INSTALL_DIR" hdc -t <UDID> shell "mkdir -p $INSTALL_DIR"
# Push signed bundles # Push signed bundles
hdc -t <UDID> file send path/to/signed $INSTALL_DIR hdc -t <UDID> file send outputs/default/bundles/signed $INSTALL_DIR
# Install all HAP/HSP in directory # Install all HAP/HSP in directory
hdc -t <UDID> shell "bm install -p $INSTALL_DIR/signed" hdc -t <UDID> shell "bm install -p $INSTALL_DIR/signed"

View File

@@ -18,14 +18,14 @@ All HAP/HSP modules must have the **same versionCode**. Mismatched versions caus
# Using Python (cross-platform) # Using Python (cross-platform)
python3 -c " python3 -c "
import zipfile, json, glob import zipfile, json, glob
for f in glob.glob('outputs/default/signed/*.hsp'): for f in glob.glob('outputs/default/bundles/signed/*.hsp'):
z = zipfile.ZipFile(f) z = zipfile.ZipFile(f)
data = json.loads(z.read('module.json')) data = json.loads(z.read('module.json'))
print(f\"{f.split('/')[-1]}: versionCode = {data['app']['versionCode']}\") print(f\"{f.split('/')[-1]}: versionCode = {data['app']['versionCode']}\")
" "
# Using unzip + grep (Linux/macOS) # Using unzip + grep (Linux/macOS)
for f in outputs/default/signed/*.hsp; do for f in outputs/default/bundles/signed/*.hsp; do
echo -n "$(basename $f): " echo -n "$(basename $f): "
unzip -p "$f" module.json | grep -o '"versionCode":[0-9]*' unzip -p "$f" module.json | grep -o '"versionCode":[0-9]*'
done done
@@ -40,7 +40,7 @@ A module should be removed from the output before installation if:
3. Module versionCode differs from `AppScope/app.json5` 3. Module versionCode differs from `AppScope/app.json5`
```bash ```bash
rm outputs/default/signed/problematic-module-default-signed.hsp rm outputs/default/bundles/signed/problematic-module-default-signed.hsp
``` ```
## Complete Installation Workflow ## Complete Installation Workflow
@@ -66,7 +66,7 @@ INSTALL_DIR="/data/local/tmp/install_$(date +%s)"
hdc -t <UDID> shell "mkdir -p $INSTALL_DIR" hdc -t <UDID> shell "mkdir -p $INSTALL_DIR"
# Push signed HAP/HSP files # Push signed HAP/HSP files
hdc -t <UDID> file send outputs/default/signed $INSTALL_DIR hdc -t <UDID> file send outputs/default/bundles/signed $INSTALL_DIR
``` ```
### Step 3: Install Application ### Step 3: Install Application
@@ -100,7 +100,7 @@ Save as `install.sh` (Linux/macOS) or run with Git Bash on Windows:
# === Configuration === # === Configuration ===
DEVICE_ID="${1:-$(hdc list targets | head -1)}" DEVICE_ID="${1:-$(hdc list targets | head -1)}"
SIGNED_PATH="${2:-outputs/default/signed}" SIGNED_PATH="${2:-outputs/default/bundles/signed}"
BUNDLE_NAME="${3:-}" BUNDLE_NAME="${3:-}"
REMOTE_PATH="/data/local/tmp/install_$(date +%s)" REMOTE_PATH="/data/local/tmp/install_$(date +%s)"
@@ -146,24 +146,22 @@ Usage:
./install.sh 1234567890ABCDEF ./install.sh 1234567890ABCDEF
# Specify device and path # Specify device and path
./install.sh 1234567890ABCDEF outputs/default/signed ./install.sh 1234567890ABCDEF outputs/default/bundles/signed
# Specify device, path, and bundle name (auto-launch) # Specify device, path, and bundle name (auto-launch)
./install.sh 1234567890ABCDEF outputs/default/signed com.example.app ./install.sh 1234567890ABCDEF outputs/default/bundles/signed com.example.app
``` ```
## Build Output Structure ## Build Output Structure
``` ```
outputs/ outputs/
└── {product}/ # e.g., default/ └── default/
── {project}-{product}-signed.app # Complete APP bundle ── bundles/
── signed/ ── signed/
├── entry-{product}-signed.hap # Main entry HAP ├── entry-default-signed.hap # Main entry HAP
├── feature-{product}-signed.hap # Feature HAP (if any) ├── feature-default-signed.hap # Feature HAP (if any)
└── *.hsp # Shared library modules └── *.hsp # Shared library modules
└── unsigned/
└── ... # Unsigned versions
``` ```
## Troubleshooting Details ## Troubleshooting Details

View File

@@ -136,7 +136,7 @@ Sometimes HSP files appear in the output directory that are **not listed in `bui
```bash ```bash
# Example: Remove modules not in build-profile.json5 # Example: Remove modules not in build-profile.json5
rm <output_path>/signed/unwanted-module-default-signed.hsp rm outputs/default/bundles/signed/unwanted-module-default-signed.hsp
``` ```
**Note:** Installation will fail with "version code not same" error if these unwanted modules have a different versionCode than the main app. The root cause is that these modules shouldn't be deployed at all. **Note:** Installation will fail with "version code not same" error if these unwanted modules have a different versionCode than the main app. The root cause is that these modules shouldn't be deployed at all.