This Guide helps you troubleshoot some of the common 2GP (Second-Generation Package) package version creation issues.
Review the features and settings in project-scratch-def.json:
enableEnhancedNotes, enableLiveAgent, enableOmniChannel)Common Issues to Check:
Resources:
Scratch Org Features
Metadata Settings
Specifying Salesforce Release
Useful Commands
# 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 pacakge with scratch org def file
sf package version create --package <package alias/ID> --installation-key-bypass -v <target-org>
Validate that all package dependencies are correctly defined in the package directory file. Below are the steps to follow:
Review sfdx-project.json:
dependencies section.Common Issues to Check:
Validation Commands:
# 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
Resources:
Create Dependencies Between Second-Generation Managed Packages
Validate that metadata can be successfully deployed to the build org without errors. Debugging Actions:
Deploy to Scratch Org, create a scratch org with scratch-org-def file with required features and settings related to metadata and install if we have dependencies:
Common Issues to Check:
Validation Commands:
# 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>
Check Package Configuration:
sfdx-project.json package configurationBuild Process Validation without code coverage to validate if required metadata is valid:
# 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>
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.