2

My scratch orgs have this feature:

"features": ["DebugApex"],

So I create a PermissionSet enable this feature on the scratch org. But when running sfdx force:source:convert --outputdir mdapi_output --packagename packageName the permission set is included and is causing failure when pushing on an org for packaging (sfdx force:mdapi:deploy --deploydir mdapi_output -u XXX).

Is there a way to exclude it from packaging ? forceignore file excludes it from pull/push on scratch and it is not the goal.

0

Just had the same sort of problem and didn't find a mechanism in SFDX for this sort of filtering.

We are using Ant as well as SFDX and that has good filtering mechanisms (and we also have files split into separate trees so need to merge those trees) so we are first copying to a new tree of files where the files we don't want are excluded and then running the convert:

<target name="clean">
    <delete dir="./mdapi-source/staged"/>
    <delete dir="./mdapi-source/cvux"/>
</target>

<target name="convert" depends="clean">
    <copy todir="./mdapi-source/staged">
        <fileset dir="./sfdx-source/int/test"/>
        <fileset dir="./sfdx-source/int/main"/>
        <fileset dir="./sfdx-source/wiz/test">
           <exclude name="**/aura/**"/>
           <exclude name="**/staticresources/**"/>
        </fileset>
        <fileset dir="./sfdx-source/wiz/main"/>
    </copy>
    <exec dir="." executable="sfdx" osfamily="unix" failonerror="true">
        <arg value="force:source:convert"/>
        <arg value="--rootdir" />
        <arg value="./mdapi-source/staged" />
        <arg value="--outputdir" />
        <arg value="./mdapi-source/cvux" />
    </exec>
</target>

There might be something that helps in the sfdx-isv/sfdx-falcon-template project that:

This template can be used as a starting point for any Salesforce DX project, but has been specialized for building managed packages. Each directory in this repository contains a README file describing its purpose, what type of files it should contain, and additional setup/configuration details (if needed).

0

Use .forceignore. As stated in the documentation:

When syncing metadata between your local file system and a scratch org, you often have source files you want to exclude. Similarly, you often want to exclude certain files when converting source to Salesforce DX project format. In both cases, you can exclude individual files or all files in a specific directory with a .forceignore file. (Emphasis added.)

  • When push to scratch as well so not a good idea. – Simon Placentino Apr 9 '18 at 7:04
0

My read of the documentation is that the .forceignore file mentioned by others is only when you're pushing and pulling to the scratch org or converting from mdapi TO DX, not the other way around.

For our team where we just ran into this, I'm writing a bash script (but it could be written in anything) that will copy the DX force-app code tree to something like mdapimidway, prune out the files we don't want to convert and deploy and then call the convert command with the midway tree as the source to convert

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

The real power of DX isn't that it has functional parity with other tools, it's that you can throw it into the middle of your own scripts to take care of all the things they didn't think of.

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.