This guide helps you troubleshoot some of the common Second-Generation Package (2GP) version creation issues in Salesforce. It covers package configuration, metadata validation, scratch org feature settings, and package dependency errors, with Salesforce CLI commands and walkthrough videos for each step.
This article walks through troubleshooting steps for common 2GP (Second-Generation Package) version creation issues in Salesforce, covering package configuration, metadata validation, scratch org feature and setting requirements, and package dependency verification.
Run a package version build without code coverage to validate that the required metadata is valid. The first command creates the package version and waits up to 10 minutes. The second command reports the build status.
# Create package version with validation sf package version create --package <package-alias> --installation-key-bypass --wait 10 # Check build status sf package version report --package-version-id <version-id>
The following video walks you through package version creation validation.
Validate that metadata can be successfully deployed to the build org without errors. Follow these debugging actions:
The following commands deploy with validation only, check metadata validity, and deploy to a scratch org for testing.
# Deploy with validation only sf project deploy start --source-dir force-app --dry-run # Check metadata validity sf project deploy validate --source-dir force-app # Deploy to scratch org for testing sf project deploy start --source-dir force-app --target-org <scratch-org-alias>
The following video walks you through verifying metadata.
The following video walks you through enabling features and settings.
The following commands validate the scratch org definition, display the org features, and create a package version using the scratch org definition file.
# Validate scratch org definition sf org create scratch --definition-file config/project-scratch-def.json --dry-run # Check org features sf org display --target-org <scratch-org-alias> # Creating a package with scratch org def file sf package version create --package <package alias/ID> --installation-key-bypass -v <target-org>
This step is required only if the package has dependencies. Validate that all package dependencies are correctly defined in the package directory file. Follow these steps:
The following commands validate the project configuration, show the dependency tree, and resolve dependencies with a validation-only deployment.
# Validate project configuration sf project validate start # Check dependency tree sf project dependency tree # Resolve dependencies sf project deploy start --source-dir force-app --dry-run
For links to the scratch org feature list, metadata settings, release selection, and dependency documentation, see Additional Resources.
005227981

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.