Thursday, 5 January 2023

2GP Locked and UnLocked Package sfdx Commands

 2GP Locked Package :

======================


Authorize a Dev Hub :


1.sfdx force:config:set defaultdevhubusername=example.xxxxx@xxxx.com


2.Add NameSapce to Sfdx-project.json file 


Before adding a namespace, make sure that you have linked the namespace to your Dev Hub org.


In the sfdx-project.json file, specify a namespace using the namespace attribute.


ex : "namespace": "myownspace"


Important : After you create a package, you can’t change or add a namespace, or change the Dev Hub the package is associated with.


Create package :

 

3.sfdx force:package:create -n locked_pkg_sample -t Managed -r force-app -d "Your 2gp Package Descripton"


create Version


4.sfdx force:package:version:create -p 0Hxxxxxxxxxxxxxxxx -x --codecoverage --wait 10


Important : Package versions are beta until you promote them to a managed-released state.


Release a Package :


5.sfdx force:package:version:promote -p 04txxxxxxxxxxxxxxxx


Install Package :


6.sfdx force:package:install -p 04txxxxxxxxxxxxxxxx --wait 10 --publishwait 10


2GP UnLocked Package :

======================


Authorize a Dev Hub :


1.sfdx force:config:set defaultdevhubusername=example.xxxxx@xxxx.com


Create package :

 

2.sfdx force:package:create -n twogpsample_demo -t Unlocked -r force-app


Create a package version :


3.sfdx force:package:version:create -p 0Hoxxxxxxxxxxxxxxxx -x --codecoverage --wait 10


Note : version creation takes time and it pass through certain steps like initialize, verify metadata and then finally create version.


=> VersionName, versionnumber is completely up to you.NEXT at the end of the versionnumber will automatically increase the number.


Release a Package :


4.sfdx force:package:version:promote --p 04txxxxxxxxxxxxxxxx


Install Package :


5.sfdx force:package:install -p 04txxxxxxxxxxxxxxxx --wait 10 --publishwait 10


No comments:

Post a Comment