Skip to main content
2 of 8
added 116 characters in body
nstuyvesant
  • 879
  • 2
  • 9
  • 22

Second-generation Managed Package with dependency on first-generation Managed Package

Creating a second-generation Managed Package (2GP) that has a dependency on a released first-generation Managed Package (1GP).

Got the information about my 1GP (namespace = xyzzy) from its Packaging and Namespace Org with:

sfdx force:package1:version:list -u [email protected] 

which displays a row with MetadataPackageVersionId = 04t..., MetadataPackageId = 033.., Name = Aurora 2023, Version = 2.1.0, ReleaseState = Released and BuildNumber = 7.

On my Dev Hub ([email protected]), I linked my namespace then created a 2GP like this:

sfdx force:package:create --name "Connector for Salesforce" --packagetype Managed --path force-app/ 

which returns NAME = Package Id, VALUE = 0Ho...

Now for the sfdx-project.json...

{ "namespace": "xyzzy", "sfdcLoginUrl": "https://login.salesforce.com", "sourceApiVersion": "56.0", "packageDirectories": [ { "default": true, "package": "Connector for Salesforce", "path": "force-app", "versionName": "Aurora 2023.2", "versionNumber": "2.1.1.NEXT", "definitionFile": "config/project-scratch-def.json", "dependencies": [ { "Connector for Salesforce (1GP)@2.1.0.7": "04t..." } ] } ], "packageAliases": { "Connector for Salesforce": "0Ho...", "Connector for Salesforce (1GP)@2.1.0.7": "04t...", "Connector for Salesforce (1GP)": "033..." } } 

When I run

sfdx force:package:beta:version:create -p 0Ho... --installationkeybypass -b next 

I get an error...

ERROR running force:package:version:create: Dependency must specify either a subscriberPackageVersionId or both packageId and versionNumber: {"Connector for Salesforce (1GP)@2.1.0.7":"04t..."}

The 04t... that I specified for the dependency is the MetadataPackageVersionId value from the 1GP. Any thoughts on where I'm going wrong? Do I have to install my released 1GP on the Dev Hub for this to work?

Update: This is what the versions for the package Connector for Salesforce should be:

Aurora 2023 (2.1.0.7) - Last release of first-generation managed package Aurora 2023.2 (2.1.1.x) - First release of second-generation managed package 
nstuyvesant
  • 879
  • 2
  • 9
  • 22