Is there anyway to specify (using Salesforce DX) that the package I want to create includes a post install script?


I don't see any parameters in the command to include it. If you create it manually it works fine, but just was wondering if it is a missed feature in Salesforce DX cli.

1 Answer 1


The postinstall script is set as part of the package.xml file, which if you're using SFDX for development you'll probably be automatically generating as part of your build script using sfdx force:source:convert.

We use a tool in our build runner called xmlstarlet which we use to inject the postInstallClass script name into the package.xml file before it is deployed to the packaging org and the package is created.

xml ed --inplace -N sfdc="http://soap.sforce.com/2006/04/metadata" \
       --subnode "/sfdc:Package" --type elem -n "postInstallClass" -v "PostInstall" \

This adds the following element to the package.xml


Alternatively you could do this using a find and replace tool like sed or by maintaining the package.xml in source.

An issue has been logged against the CLI to allow this and other package related attributes (uninstall script, release notes link etc.) to be specified in the force:source:convert command.

  • Thanks - this is a great tip. We needed something ideally without any external tools, so I'm using the following in our windows based script (bit of a bodge but works well enough for us): powershell -Command "(gc mdapi_output_dir/package.xml) -replace '</Package>', '<postInstallClass>PostInstallScript</postInstallClass></Package>' | Out-File -encoding UTF8 mdapi_output_dir/package.xml". Linux based would of course be trivial using sed.
    – berry120
    Mar 19, 2019 at 15:19

You must log in to answer this question.

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