package version create

Create a package version in the Dev Hub org.

The package version is based on the package contents in the specified directory.

To retrieve details about a package version create request, including status and package version ID (04t), run “sf package version create report -i 08c…”.

We recommend that you specify the –installation-key parameter to protect the contents of your package and to prevent unauthorized installation of your package.

To list package version creation requests in the org, run “sf package version create list”.

To promote a package version to released, you must use the –code-coverage parameter. The package must also meet the code coverage requirements. This requirement applies to both managed and unlocked packages.

We don’t calculate code coverage for org-dependent unlocked packages, or for package versions that specify –skip-validation.

force:package:version:create

Flag Name (Long)Flag Name (Short)Description
‑‑api‑versionN/AType: Value

Override the api version used for api requests made by this command
‑‑async‑validationN/AType: Boolean

Return a new package version before completing package validations.

Specifying async validation returns the package version earlier in the process, allowing you to install and test the new version right away. If your development team is using continuous integration (CI) scripts, async validation can reduce your overall CI run time.
‑‑branch‑bType: Value

Name of the branch in your source control system that the package version is based on.
‑‑code‑coverage‑cType: Boolean

Calculate and store the code coverage percentage by running the packaged Apex tests included in this package version.

Before you can promote and release a managed or unlocked package version, the Apex code must meet a minimum 75% code coverage requirement. We don’t calculate code coverage for org-dependent unlocked packages or for package versions that specify –skip-validation.
‑‑definition‑file‑fType: Value

Path to a definition file similar to scratch org definition file that contains the list of features and org preferences that the metadata of the package version depends on.

For a patch version, the features specified in this file are ignored, and instead the features specified for the ancestor version are used.
‑‑flags‑dirN/AType: Value

Import flag values from a directory.
‑‑generate‑pkg‑zipN/AType: Boolean

Generate a package ZIP file that you can use for debugging or to examine the package contents.
‑‑installation‑key‑kType: Value

Installation key for key-protected package. (either –installation-key or –installation-key-bypass is required)
‑‑installation‑key‑bypass‑xType: Boolean

Bypass the installation key requirement. (either –installation-key or –installation-key-bypass is required)

If you bypass this requirement, anyone can install your package.
‑‑jsonN/AType: Boolean

Format output as json.
‑‑languageN/AType: Value

Language for the package.

Specify the language using a language code listed under “Supported Languages” in Salesforce Help. If no language is specified, the language defaults to the language of the Dev Hub user who created the package.
‑‑package‑pType: Value

ID (starts with 0Ho) or alias of the package to create a version of.
‑‑path‑dType: Value

Path to the directory that contains the contents of the package.
‑‑post‑install‑scriptN/AType: Value

Name of the post-install script; applies to managed packages only.

The post-install script is an Apex class within this package that is run in the installing org after installations or upgrades of this package version.
‑‑post‑install‑urlN/AType: Value

Post-install instructions URL.

The contents of the post-installation instructions URL are displayed in the UI after installation of the package version.
‑‑releasenotes‑urlN/AType: Value

Release notes URL.

This link is displayed in the package installation UI to provide release notes for this package version to subscribers.
‑‑skip‑ancestor‑checkN/AType: Boolean

Override ancestry requirements, which allows you to specify a package ancestor that isn’t the highest released package version.
‑‑skip‑validationN/AType: Boolean

Skip validation during package version creation; you can’t promote unvalidated package versions.

Skips validation of dependencies, package ancestors, and metadata during package version creation. Skipping validation reduces the time it takes to create a new package version, but you can promote only validated package versions. Skipping validation can suppress important errors that can surface at a later stage. You can specify skip validation or code coverage, but not both. Code coverage is calculated during validation.
‑‑tag‑tType: Value

Package version’s tag.
‑‑target‑dev‑hub‑vType: Value
Required

Username or alias of the Dev Hub org. Not required if the target-dev-hub configuration variable is already set.
‑‑uninstall‑scriptN/AType: Value

Uninstall script name; applies to managed packages only.

The uninstall script is an Apex class within this package that is run in the installing org after uninstallations of this package.
‑‑verboseN/AType: Boolean

Display verbose command output.

Display verbose command output. When polling for the status of the creation, this will output status and timeout data on a separate line for each poll request, which is useful in CI systems where timeouts can occur with long periods of no output from commands.
‑‑version‑description‑eType: Value

Description of the package version to be created; overrides the sfdx-project.json value.
‑‑version‑name‑aType: Value

Name of the package version to be created; overrides the sfdx-project.json value.
‑‑version‑number‑nType: Value

Version number of the package version to be created; overrides the sfdx-project.json value.

For information about the format of the version number, see https://developer.salesforce.com/docs/atlas.en-us.pkg2_dev.meta/pkg2_dev/sfdx_dev2gp_config_file.htm.
‑‑wait‑wType: Value
Default value: 0 minutes

Number of minutes to wait for the package version to be created.

Create a package version from the contents of the “common” directory and give it an installation key of “password123”; uses your default Dev Hub org:

Create a package version from a package with the specified alias; uses the Dev Hub org with username devhub@example.com:

Create a package version from a package with the specified ID:

Create a package version and skip the validation step:

Create a package version and perform package validations asynchronously: