Exclude objects from other packages in sfdx

custom-objectexclusion-scriptsalesforcedxunlocked-package

How to exclude objects from other packages (prefix) in sfdx? Since I created a dependent unlocked package when I add custom fields to objects of the "needed/parent" package when I retrieve the custom field sfdx also retrieves the object which later results in an error since we cannot overwrite components of another package.

How kan ik exclude objects from another package?

** Update:

My .forceignore file is in the root folder of my project.

  • I created a map ignore under the default map
  • I tried adding /force-app/main/default/ignore to the .forceignore file
  • I tried adding force-app/main/default/ignore .forceignore file

I get the same error : Must specify a non-empty label for the CustomObject

Which is resolved if I remove the object of the other package from my package

** Update:

Here is my force ignore file this is at the root of my project

# .forceignore v2
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
#

package.xml
force-app/main/default/ignore
# LWC configuration files
**/jsconfig.json
**/.eslintrc.json

# LWC Jest
**/__tests__/**

Best Answer

Manually move the object files into another directory after retrieval and add the new directory into the .forceignore