I am trying to create a managed package version for 2GP using salesforce CLI, after running force:package:version:create command I am getting thousands of errors in the terminal I am only able to see a portion of the errors in the terminal which say "Invalid type : namespace__CustomObject__c" for every custom object, setting or metadata, and consequently throws errors like "Variable does not exist: var2" or DML requires SObject or SObject list type: List<namespace__CustomObject__c>.
I have followed following approach to create the package -
- created DX project and authorised dev hub org, dev hub org is already linked with the namespace org which is also our source org
- created scratch org of "partner developer" edition
- pushed all metadata to the scratch org
- created package
- ran package:version:create command - after this I am getting all errors in Verifying Metadata stage
Here is how the config.json looks like
{
"packageDirectories": [
{
"path": "force-app",
"default": true,
"package": "packageName-MP-v1.0",
"versionName": "ver 1.0",
"versionNumber": "1.0.0.NEXT"
}
],
"name": "packageName",
"namespace": "namespace",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "55.0",
"packageAliases": {
"packageName-MP-v1.0": "0Ho.."
}
}
and this is the project-scratch-def.json
{
"orgName": "packageName Scratch Org",
"edition": "Partner Developer",
"features": ["EnableSetPasswordInApi"],
"settings": {
"lightningExperienceSettings": {
"enableS1DesktopEnabled": true
},
"mobileSettings": {
"enableS1EncryptedStoragePref2": false
}
}
}
Am I missing something in scratch org definition?
Any help is appreciated Thank you!