Retrieve metadata to a custom folder by using default method “Retrieve Source in Manifest ORG” in Visual Studio

salesforcedxsfdx-pluginvisualstudiocode

In my ORG I didn't add to repository the default folders like so

enter image description here

It was done like the following image:

enter image description here

That is, the root files starts in src/ folder instead of force-app/main/default/*

It brings some issues and rework. All the time that I retrieve some metadata from the some sandbox, the command "Retrieve Source in Manifest ORG" creates another folder based on force-app/main/default/*. Take a look at the green folder.

It happens when I am trying to retrieve by using the manifest file:

enter image description here

I have already added this structure in the sfdx-project.json file in the following way:

{
  "packageDirectories": [
    {
      "path": "repo/src",
      "default": true
    }
  ],
  "name": "ORGDEVTEAM",
  "namespace": "",
  "sfdcLoginUrl": "https://mydomain.lightning.force.com/",
  "sourceApiVersion": "52.0"
}

It works! It allows me deploying and retrieving the files by right-clicking and selecting the appropriate command, but when I am using the approach of retrieving by using the manifest package.xml, it creates a new structure folder outside of repo/src folder.

How to avoid that?

Best Answer

The format that you are using is outdated.

The previous format does not support new innovations like below

  • Ability to use Source Tracking
  • No more need to maintain package.xml in Source folder
  • Create 2GP packages from the Source folder
  • Ability to break Custom Object metadata into manageable format

You can read more here.

Hence I suggest you move to source format using sfdx force:mdapi:convert -r mdapi-source/original-package

You can preserve the source control git history using technique listed here.