Hi ,
Here we are going to learn how to create a Second Generation Managed Package and how to install the same.
Before you create a Second Generation Managed Package , we have to complete the following things.
- Create a Developer Edition org if you don't have already and configure a name space
- Now Enable DevHub and Second Generation package where you want to register your name space(If you are implementing AppExchange product then Salesforce Recommends to d the same in PBO org)
Now you are ready to create a Second Generation Managed Package.
- Authorize DevHub using the following command via command prompt or vs code
sfdx force:auth:web:login -d -a DevHub
- Check you sfdx-project.json and include your name. Here I have included name space called "Balu131"
sfdx-project.json
{
"packageDirectories": [
{
"path": "force-app",
"default": true
}
],
"namespace": "Balu131",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "50.0"
}
- Create a package using the following command
sfdx force:package:create --name "test2GPManged" --path force-app --packagetype Managed -- targetdevhubusername DevHub
once it is completed then it adds the verionName,versionNumber and packageAliases to your sfdx-project.json file.
{
"packageDirectories": [
{
"path": "force-app",
"default": true,
"package": "test2GPManged",
"versionName": "ver 0.1",
"versionNumber": "0.1.0.NEXT"
}
],
"namespace": "Balu131",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "50.0",
"packageAliases": {
"test2GPManged": "0Ho09000000wk90CAA"
}
}
- Create a version using the following command
sfdx force:package:version:create --package "test2GPManged" --installationkey test1234 --wait 10 -v DevHub
or
sfdx force:package:version:create --package "test2GPManged" --installationkey test1234 --wait 10 --codecoverage -v DevHub
- Promote your package version (Note: to promote we always need to run test classes with the help of --codecoverage parameter while creating version above.
sfdx force:package:version:promote -p test2GPManged@1.0.0-1 -v DevHub
- Install your managed package into destination org.
sfdx force:package:install --package "test2GPManged@1.0.0-1" --targetusername PackageDemoOrg --installationkey test1234 --wait 10 --publishwait 10
No comments:
Post a Comment