1

When I type:

sfdx package:version:create -p 0Ho... --installation-key-bypass -b 2gp-internal

I get an error:

ERROR running force:package:version:create: Can’t create patch version. Log a case in the Salesforce Partner Community and request that patch versioning be enabled in the org where you created the namespace for this package.

Several days ago, I opened a ticket with Salesforce Support to enable patch versioning on that org and they said they could not unless the app had undergone security review (which is hard since I can't create a version of the app so it can be reviewed).

The Namespace Org contains a 1GP with two Connected Apps and a released managed package (version 2.2.0.7) with a namespace that matches my sfdx-project.json. As an aside, the Connected Apps support an Aura Component Bundle that is a Canvas App so I followed instructions on this page of the Salesforce DX Developer Guide.

This is what my sanitized sfdx-project.json contains:

{
  "namespace": "sumthin",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "56.0",
  "packageDirectories": [
    {
      "default": true,
      "path": "force-app",
      "package": "Company Connector for Salesforce (Internal)",
      "versionName": "Aurora 2023.1",
      "versionNumber": "2.2.1.NEXT",
      "versionDescription": "Some description",
      "postInstallScript": "MyPostInstall",
      "branch": "2gp-internal",
      "definitionFile": "config/project-scratch-def.json"
    },
    {
      "default": false,
      "path": "force-app",
      "package": "Company Connector for Salesforce",
      "versionName": "Aurora 2023.1",
      "versionNumber": "2.2.1.NEXT",
      "versionDescription": "Some description",
      "postInstallScript": "MyPostInstall",
      "branch": "2gp",
      "definitionFile": "config/project-scratch-def.json"
    },
    {
      "default": false,
      "path": "force-app",
      "package": "Company Connected Apps",
      "versionName": "Aurora 2023",
      "versionNumber": "2.2.0.7",
      "versionDescription": "Support for Company Connector for Salesforce"
    }
  ],
  "packageAliases": {
    "Company Connector for Salesforce": "0Ho...",
    "Company Connector for Salesforce (Internal)": "0Ho...",
    "Company Connected [email protected]": "04t...",
    "Company Connected Apps": "033..."
  }
}

The last package is only there to document Ids since it's a 1GP that contains the Connected Apps (on the namespace org).

Here's a sanitized version of the ConnectedApp metadata in the 2GP that points back to the Connected App in the released 1GP in the namespace org (developer name has the namespace prefix and the API name of the Connected App in the 1GP)...

<?xml version="1.0" encoding="UTF-8" ?>
<ConnectedApp xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>1.0</version>
    <developerName>sumthin__CompanyInternalConnectedApp</developerName>
    <label>Company Connector for Salesforce (Internal)</label>
    <description>Allows users to add Company views to Salesforce</description>

    <logoUrl>https://www.example.com/logo.png</logoUrl>
    <infoUrl>https://www.example.com</infoUrl>
    <contactEmail>[email protected]</contactEmail>

    <canvasConfig>
        <accessMethod>Post</accessMethod>
        <canvasUrl>https://something.example.com</canvasUrl>
        <lifecycleClass>MyCanvasLifecycle</lifecycleClass>
        <locations>Visualforce</locations>
        <locations>Aura</locations>
        <locations>ServiceDesk</locations>
        <locations>PageLayout</locations>
        <samlInitiationMethod>None</samlInitiationMethod>
    </canvasConfig>

</ConnectedApp>

Any thoughts as to where I may have gone wrong?

2 Answers 2

2

The error from

sfdx package:version:create -p 0Ho... --installation-key-bypass -b 2gp-internal

suggesting that patch versioning needed to be activated on the namespace org was COMPLETELY ERRONEOUS. Unfortunately, I dutifully followed the error's guidance and opened a Salesforce Support ticket requesting patch versioning and they closed it because the app hasn't been through security review. Bit of a chicken-and-egg problem if I can't build the version of the 2GP to submit for security review.

Anyway, the issue was that I was trying to align the 2GP's first version where I left off on the 1GP. I wasn't trying to make a 2GP that would be possible for customers to upgrade from the 1GP. I just wanted the versioning to make sense. So if the last version of the 1GP was 2.1.0.7, the 2G would start at 2.2.1.NEXT. This caused the sfdx package version create to wonder where the previous version was which led to the assumption I needed patch versioning.

Here is the corrected sfdx-project.json...

{
  "namespace": "sumthin",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "57.0",
  "packageDirectories": [
    {
      "default": true,
      "path": "force-app",
      "package": "Company Connector for Salesforce (Internal)",
      "versionName": "Aurora 2023.1",
      "versionNumber": "1.0.0.NEXT",
      "versionDescription": "Some description",
      "postInstallScript": "MyPostInstall",
      "branch": "2gp-internal",
      "definitionFile": "config/project-scratch-def.json"
    },
    {
      "default": false,
      "path": "force-app",
      "package": "Company Connector for Salesforce",
      "versionName": "Aurora 2023.1",
      "versionNumber": "1.0.0.NEXT",
      "versionDescription": "Some description",
      "postInstallScript": "MyPostInstall",
      "branch": "2gp",
      "definitionFile": "config/project-scratch-def.json"
    },
    {
      "default": false,
      "path": "force-app",
      "package": "Company Connected Apps",
      "versionName": "Aurora 2023",
      "versionNumber": "2.2.0.7",
      "versionDescription": "Support for Company Connector for Salesforce"
    }
  ],
  "packageAliases": {
    "Company Connector for Salesforce": "0Ho...",
    "Company Connector for Salesforce (Internal)": "0Ho...",
    "Company Connected [email protected]": "04t...",
    "Company Connected Apps": "033..."
  }
}

I'm feeling a bit salty about this because I could have saved a lot of time had I gotten a better error message.

I hope my woes help others avoid the same mistake.

0

Ran into a similar issue. Just had to change my "versionName" to start with 1. Apparently it doesn't like 0.0.1 as a version number

1
  • Tried incrementing my version but it was already at 1.0.0.NEXT. Unfortunately, no change in the result. Apr 17, 2023 at 14:07

You must log in to answer this question.

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