5

I've been developing my application using a Salesforce DX trial org (and accompanying CLI). My sfdc-project.json file is setup to use two paths for the source code as follows:

{ ...
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    },
    {
      "path": "http-sdk"
    }
  ],
...
}

This has worked well for me to split my code base up between my app code and a set of HTTP API SDK classes I use. However, now that I'm trying to convert the project to an MDAPI format for packaging and distribution in the AppExchange, I noticed that the sfdx force:source:convert -d mdapioutput/ command only outputs the contents of the default path from my config.

1
  • did you ever figure this out?
    – NSjonas
    Commented Dec 20, 2017 at 4:12

3 Answers 3

3

If you run the command multiple times with the same output directly:

sfdx force:source:convert -r force-app -d mdapioutput/
sfdx force:source:convert -r http-sdk -d mdapioutput/

it does seem to merge the files correctly, but it does not properly merge the package.xml (will be overwritten with the last commands xml).

However, while undocumented, that you can put multiple packages under force-app and do something like this:

File Structure

- force-app
-- main
---- classes
---- pages
-- http-sdk
---- classes
---- pages

sfdx-project.json

{ ...
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    },
    {
      "path": "force-app/main"
    },
    {
      "path": "force-app/http-sdk"
    }
  ],
...
}

You can then run: sfdx force:source:convert -r force-app -d mdapioutput/ to package both.

With this setup you can still package both individually:

sfdx force:source:convert -r force-app/http-sdk -d mdapioutput/

Disclaimer : I haven't tested this setup with scratch orgs so I'm not sure if force:source:pull and force:source:pull will work properly.

1

You will need to indicate the root as well for the source convert

Have you tried below

sfdx force:source:convert -r http-sdk -d mdapioutput/
2
  • Unfortunately it just uses that folder to copy the contents into the mdapioutput directory. I tried using -r http-sdk,force-app and that fails completely as it looks like it uses the -r argument to build just a single path.
    – Blake
    Commented Oct 31, 2017 at 22:50
  • I guess you will need to run convert command first with force-app and then with http-sdk for this . Commented Nov 1, 2017 at 0:25
0

It's a bit late but I came into this issue and to fix it I've used the following, it has packaged my 3 packages together in the mdapioutput dir

sfdx force:source:convert -d mdapioutput/ -r . 

You must log in to answer this question.

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