[SalesForce] Generate sfdx-project.json

I would like to create a new version of my package. I work with Jenkins so I clone my git repository once time ==> my sfdx-project.json is in default :

sfdx-project.json :

{
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    }
  ],
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "44.0"
}

How can I update my sfdx-project.json to use sfdx force:package:version:create ?

I would like a command to update my local sfdx-project.json

My error is like :

ERROR running force:package:version:create: The package MyPackageName isn’t defined in the sfdx-project.json file. Add it to the packageDirectories section and add the alias to packageAliases with its 0Ho ID.

Best Answer

Trudy is correct that you need to either 1. Create a package first (not a package version), OR 2. You need to have those details in your sfdx-project.json file.

This is what you have now:

{
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    }
  ],
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "44.0"
}

But with a package created it should look something like this:

{
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
      "package": "myPkgAlias",
      "versionName": "1.0.0",
      "versionNumber": "1.0.0.NEXT",
    }
  ],
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "46.0",
  "packageAliases": {
    "myPkgAlias": "0Ho000000000000001"
  }
}

You need to provide the following properties in your package directory along with an alias to use for your package.

"package": "myPkgAlias",
"versionName": "1.0.0",
"versionNumber": "1.0.0.NEXT",

You also need the "packageAliases" section with at least one entry associating the package alias that you chose with the "0Ho*" package id.

"packageAliases": {
  "myPkgAlias": "0Ho000000000000001"
}

You can get the list of packages with the "0Ho*" package ids for your DevHub using:

sfdx force:package:list

Note that if your open project's sfdx-project.json file has a package alias defined it will show the alias in the returned list of packages.

See Project Configuration File for Packages in the Salesforce DX documentation for more information about the project file.

Related Topic