2

Before DX I always had this in my .gitignore:

/src/package.xml

Now I am migrating to DX and a package.xml got created in my root somehow. Back in the days, I excluded the file because I thought that locally each developer might have different data pulled from the server (even I did it differently on a per-use basis) but with the migration to DX where you basically have everything versioned in the source format I'm not sure if this approach is still correct. Also, is this file even needed in the DX era? If so - where? Is the root correct or did it end up there by accident?

  • 1
    With SFDX in source format there is no need and no use of the package.xml. There is, however, a need and usage of package.json especially when you use jest for LWC unit testing. – Phil W Sep 29 at 10:00
3

package.xml is only used for the mdapi metadata format. If you're not using a src folder with DX, you don't need a package.xml. There are commands in DX that use this file, but this is really only meant to help you migrate from the older format to the superior source format used by DX for Unlocked Packages and so on.

Note that because the mdapi complains if there are missing or extra files, it was traditionally important to have at least one full package.xml versioned so that developers had a way to deploy/retrieve package contents. Without it, they had to manually create these files, and it could be very time consuming. This was one of the major limitations of the mdapi format, and the reason why source format doesn't use it.

You may still want to have a package.xml available in case you need to rebuild a mdapi format directory, but this is optional, as you can always use force:source:convert to get back to a mdapi format directory if you need to. This makes it largely redundant to keep a versioned package.xml in your repo anywhere.

If you're still using mdapi format, you should not ignore package.xml, but rather keep it up to date. Developers should copy it and modify it in a separate directory, but always keep a master listing of this file in the repo that contains a full listing. Once you move to source format, you don't need to keep this file around.

| improve this answer | |
  • 1
    This was precisely the answer I was looking for. Very detailed! Thanks for sharing your knowledge! – Semmel Sep 29 at 10:26
2

when you create dx project, you get these three options using Salesforce CLI:-

enter image description here

When you opt for creating project with manifest, a package xml file will be generated inside the project folder structure whereas when you do go for without manifest, it will not.

sfdx force:project:create -n MyProject --manifest

Read more about creating SFDX project :- Create a Salesforce DX Project

| improve this answer | |
  • Interestingly enough the package.xml does get created under manifest and not the root when you supply that option. – Semmel Sep 29 at 10:20

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.