1

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.

3

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.

| improve this answer | |
1

I think you should create package before creating package version (as command below):

sfdx force:package:create --name dreamhouse --description "My Package" --packagetype Unlocked --path force-app --nonamespace --targetdevhubusername DevHub
| improve this answer | |
  • I think you don't understand really my question. I'm on jenkins environment. My package as already be created but on other environnement. My sfdx-project.json on my machine is also not updated. – Uruca May 20 '19 at 9:20
1

It works the other way round:

The commands sfdx force:package:create and sfdx force:package:version:create will update your sfdx-project.json file automatically.

When you create the new version with Jenkins, you must push the changes to the git repository and pull the changes back to your local computer.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.