While implementing a Salesforce Package Version for my private Salesforce package, I encountered an interesting fact: The creation of the Salesforce Package Version is only possible if the right corresponding Scratch Org Definition file is provided.
I noticed that the issue when I wanted to create a custom field that is dependent on the “Person Account” feature.
1. I first modified my scrtach org permission file to enable personaccounts.
2. I created a new scratch org.
3. After creating and adding a new field that dependet on Person accounts, I tried to create a new package version.
4. My new package version was rejected with the following error message:
ERROR: Account.Person_Account__c: Field IsPersonAccount does not exist. Check spelling.
The error message does not indicate what is actually the issue. The system just suggest that the IsPersonAccount field is not existing.
The solution is comparable obvious. The Scratch Org Definition File is missing. As indicated in the documentation the file is not mandatory. However, it is required in case the package is dependent on specific Salesforce Org Features:
-f | –definitionfile DEFINITIONFILE Optional
The 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.
By including the scratch org definition file the package version could be created easily without any further issues.
Learning: The scratch org definition file is not mandatory, but required in case the package is refering to any specific Salesforce feature.