11

I have an SFDX format project that contains some components but I do not want any profiles to be present.

When I do a:

sfdx force:source:status

to see what files would transferred by a sfdx force:source:pull, I get this result:

=== Source Status
STATE           FULL NAME                                         TYPE          PROJECT PATH
──────────────  ────────────────────────────────────────────────  ────────────  ────────────────────────────────────────────────────────────────
Remote Add      IntakeRelationship__c.Intake__c                   CustomField
Remote Add      IntakeRelationship__c.Contact__c                  CustomField
Remote Add      IntakeRelationship__c.Account__c                  CustomField
Remote Add      IntakeRelationship__c.Type__c                     CustomField
Remote Add      Admin                                             Profile
Remote Add      Custom: Sales Profile                             Profile
Remote Add      Custom: Marketing Profile                         Profile
Remote Add      Custom: Support Profile                           Profile
Remote Add      IntakeRelationship__c-Intake Relationship Layout  Layout
Remote Changed  Intake__c                                         CustomObject  sfdx-source/wiz/main/objects/Intake__c/Intake__c.object-meta.xml
Remote Add      IntakeRelationship__c                             CustomObject

I have tried various .forceignore values (such as **profiles and Profile/Admin) based on How to Exclude Source When Syncing or Converting and other Googling trying to exclude the profiles. But I am now thinking that the problem may be that there is not a "PROJECT PATH" for the profiles so there is nothing to match.

How can I stop the profiles from being pulled in this case?

(Pulling them and then deleting them is not an option because then the next push will try to delete them from the scratch org.)

6 Answers 6

10

I use this line in .forceignore for that:

force-app/main/default/profiles

The path should be relative to where your .forceignore lives

3
  • Thanks Denis. I think **profiles amounts to the same thing but tried the full path in case and the profiles are still being listed by sfdx force:source:status...
    – Keith C
    Commented Feb 2, 2018 at 13:43
  • 2
    As described in the answer I posted the pull does work; the status doesn't present the correct information.
    – Keith C
    Commented Feb 2, 2018 at 17:27
  • 1
    Note if you want some profiles, you can exclude all and then not exclude the ones you want. For example, if you want only the Admin profile: On one line: **profiles and on the line after it !**/profiles/Admin.profile-meta.xml Commented Feb 24, 2021 at 2:55
8

FYI, when pulling from the scratch org and not wanting to include profiles, I found that **profiles does not work, but **profile does.

1
  • +1 on this. Not sure if this changed since OP selected the answer. Commented Sep 1, 2018 at 1:21
7

Based on Denis's answer, I just went ahead and did the pull with this in .forceignore:

**profiles

and got this result:

=== Pulled Source
STATE    FULL NAME                                         TYPE          PROJECT PATH
───────  ────────────────────────────────────────────────  ────────────  ─────────────────────────────────────────────────────────────────────────────────────────────────
Add      IntakeRelationship__c                             CustomObject  sfdx-source/main/default/objects/IntakeRelationship__c/IntakeRelationship__c.object-meta.xml
Add      IntakeRelationship__c.Account__c                  CustomField   sfdx-source/main/default/objects/IntakeRelationship__c/fields/Account__c.field-meta.xml
Add      IntakeRelationship__c.Contact__c                  CustomField   sfdx-source/main/default/objects/IntakeRelationship__c/fields/Contact__c.field-meta.xml
Add      IntakeRelationship__c.Intake__c                   CustomField   sfdx-source/main/default/objects/IntakeRelationship__c/fields/Intake__c.field-meta.xml
Add      IntakeRelationship__c.Type__c                     CustomField   sfdx-source/main/default/objects/IntakeRelationship__c/fields/Type__c.field-meta.xml
Changed  Intake__c                                         CustomObject  sfdx-source/wiz/main/objects/Intake__c/Intake__c.object-meta.xml
Add      IntakeRelationship__c-Intake Relationship Layout  Layout        sfdx-source/main/default/layouts/IntakeRelationship__c-Intake Relationship Layout.layout-meta.xml
Add      Security                                          Settings      sfdx-source/main/default/settings/Security.settings-meta.xml

which is what I wanted.

So it looks like despite this documentation How to Exclude Source When Syncing or Converting saying:

The .forceignore file excludes files when running force:source:push, force:source:pull, and force:source:status. For source:status, remote changes are checked against entries in the .forceignore file. Let’s say you added a class called HelloWorld.cls on the server and included an entry in .forceignore that matches the file name (such as HelloWorld.cls or HelloWorld.*). The source:status output omits the HelloWorld.cls.

the status and pull are not consistent in this case.

1
  • Cheers for the heads up. This is some good information :) Commented Feb 2, 2018 at 14:16
4

You can also use **/profiles. The force-app/main/default/profiles will only apply to the default force-app folder, so if your DX project becomes more complex with different folders, and you want to exclude profiles from all folders, simply adding **/profiles line will exclude profiles from all folders/packages.

2

I have noticed that there is still, in July 2021, inconsistent behaviour between force:source:status and force:source:pull. To ignore the four profiles I included the following in my .forceignore file:

# Ignore profiles
Admin.profile
Custom%3A Sales Profile.profile
Custom%3A Marketing Profile.profile
Custom%3A Support Profile.profile
force-app/main/default/profiles/Custom%3A Sales Profile.profile-meta.xml
force-app/main/default/profiles/Custom%3A Marketing Profile.profile-meta.xml
force-app/main/default/profiles/Custom%3A Support Profile.profile-meta.xml

The first four (uncommented) lines were required for the profiles to be ignored by the force.source.status command and the last three for the profiles to be ignored by the force.source.pull command.

2
  • Hello Ivan, welcome to SFSE. Please take a moment to scroll though the tour and read How to Ask and How to Answer, if you haven't already. It seems like most of this post is an attempt to answer, but you do have a question at the end. If you are looking for a further discussion, you should post that as a Question, as Answer posts are not made for that purpose. If not, then again, welcome to the community.
    – Adrian Larson
    Commented Jul 11, 2021 at 2:20
  • Apologies for the mixed post Adrian, I've removed the confusing question and left the answer. Commented Jul 24, 2021 at 22:40
0

For me *.profile worked as there were couple of profiles which still couldn't be ignored

You must log in to answer this question.

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