2

Our managed package had a Post Install Script defined which was working fine.

For some undiagnosed reason (perhaps because we started using SFDX?) the Post Install Script setting was erased in a recent update to our patch development org.

Does anyone know how this setting could have been erased, and/or if there is a way to restore it short of moving to a new major release?

Thanks!

1

2 Answers 2

4

I found a solution for this by manually editing the package.xml in the metadata folder to add the missing settings before running sfdx force:mdapi:deploy

More precisely:

  1. Run sfdx force:source:convert --outputdir output --packagename "Package Name"
  2. Edit output/package.xml to add <postInstallClass>MyPostInstallClass</postInstallClass> (and other settings for the package) under the top-level <Package> element
  3. Run sfdx force:mdapi:deploy --deploydir output

To avoid doing this every time it's also possible to do the install in two steps:

  1. Create a deploy directory without specifying the package (as suggested by @Dhanasekaran) and upload it:

    sfdx force:source:convert --outputdir output --rootdir src/my-package sfdx force:mdapi:deploy --deploydir output

  2. Upload an overlay with only the package settings

    sfdx force:mdapi:deploy --deploydir config

Where the config directory contains:

  • package.xml

    With only the top level settings and the install/uninstall scripts, like:

    <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <fullName>My Package</fullName> <postInstallClass>MyPostInstallClass</postInstallClass> </Package>

  • classes

    • MyPostInstallClass.cls
    • MyPostInstallClass.cls-meta.xml
1

If you are using to convert command with packagename option, try not using that option.

sfdx force:source:convert --rootdir src/force-app --outputdir output
sfdx force:mdapi:deploy --deploydir output
1
  • Thanks @Dhanasekaran -- I believe this solution avoids overwriting the setting if it was still there, but I don't think it restores it once it is gone. See the answer I just posted for a solution to the latter problem Jan 24, 2018 at 6:32

You must log in to answer this question.

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