1

I started development of my app using 2nd Gen Packages as recommended but I've hit a couple of bugs - one which is a blocker. However during that time I've used my Package prefix in quite a lot of other places. How can I use the same prefix on a 1st Generation Package?

Edit: I tried to just create a 1GP but am unable to create a managed one with the prefix - only unmanaged without the prefix.

Unable to create managed 1GP

2 Answers 2

4

You can't migrate a 2GP into a 1GP. However, if you log in to the Developer Edition that has the namespace registered, you can create a 1GP in that org, and deploy the metadata to that org. You can only ever have one 1GP package per namespace, and it must be in the org where the namespace is registered, but you can still create other 2GP packages using that namespace. One other caveat before doing this: a 1GP cannot be installed in an org with a 2GP in the same namespace, and 2GP packages can't be installed in an org with the 1GP package in that namespace.

8
  • Thanks, however when I attempt to create the 1GP I can't seem to set it as managed. I tried the command line sf package1 version create ... --managed-released which said it was successful but the UI still shows it as "type: unmanaged".
    – mjaggard
    Commented Jan 29 at 12:02
  • I can't delete the 2GP because "Second-generation managed packages that have been promoted to released can’t be deleted."
    – mjaggard
    Commented Jan 29 at 12:07
  • @mjaggard You'll need to make the package managed in the UI, I think.
    – sfdcfox
    Commented Jan 29 at 12:32
  • Also, when I've installed the 1GP package the objects have all been created without the prefix at all.
    – mjaggard
    Commented Jan 29 at 13:03
  • that option is greyed out in the UI which is why I tried the CLI.
    – mjaggard
    Commented Jan 29 at 13:04
0

As shared by @sfdcfox there's no direct migration path from 2GP to 1GP but it is possible if you work around the differences between the package types.

  • 2nd Gen Packages can (and are encouraged to) be in a different Org to the one that owns the namespace. To create a 1st Gen Package you must be directly in the org that owns the namespace.
  • You will need to switch to the Namspace-owning Org and then push all your code using (for example) "Deploy Source to Org" in VS Code.
  • The Dev Hub must be enabled in the org.
  • You will have to manually add all the items that you want to be packaged which means clicking through all the options in the "Component Type" drop down on the "Add Component" page of the 1st Gen Package.
  • You can only have a single 1st Gen Package per namespace.
  • Don't use the CLI, it lies in its results
    • For example if you use sf package1 version create ... --managed-released then the CLI will tell you the package version was created and you can get the URL. The CLI will also tell you that it is released but in reality, it is not even managed.
  • Of course this only gets you past this bug and on to the next, you'll likely be better off moving away from Salesforce.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .