How to specify managed package dependency

My unlocked package (DX project) depends on a package from the app store, so a managed package.

How do I correctly specify this in the project file? During development I’ve manually installed the package in every scratch org, but it fails during package:version:create. I guess it is the dependency that fails…

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

On the commandline, find the package ID of the managed package you depend on. You can list all packages like this:

sfdx force:package:installed:list -u ORG_ALIAS_EG_PROD_OR_SANDBOX

Then you’d just add this to the dependency section (the Id starting with 04t…) e.g.

"dependencies": [
    {
       "package": "PACKAGE_ID_HERE"
    }
],

I’ve also seen examples where you’d use package aliases, but it seems to do the same:

"dependencies": [
    {
       "package": "some_alias_here"
    }
],

...
packageAliases : {
    "some_alias_here":"04t........."
}

Anyway, even with all the dependencies correct, remember that, at the time of writing (Sep’18), unlocked packages is still in beta so not everything may work, at least id didn’t for me.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x