[SalesForce] Metadata converted from Metadata API won’t push to scratch org with SFDX

I'm trying to convert one of my company's apps to Salesforce DX for continued development, but pushing the source retrieved from the current Developer Edition org isn't working.

I've created a new SFDX Project, and haven't changed the scratch org definition file.

For this app, there is a Developer Edition org where we handle all development and packaging. I used the Metadata API to download the managed package, using the command:

sfdx force:mdapi:retrieve -s -u user@company.net -p "App Name" -r ./mdapipkg

This gave me a file, unpackaged.zip. I unzipped that package, and converted it using the following:

sfdx force:mdapi:convert -r ./mdapipkg

I have a scratch org ready to go, spun up from our company's Dev Hub. I'm logged into that scratch org using the browser-based flow. I tried to push the now converted source to that scratch org using:

sfdx force:source:push -u scratch-org@demo_company.net

This gives me a list of errors. Among them, all of the Apex classes have an error saying that a certain Visualforce Page doesn't exist. Many of those classes don't reference that page. The issue is, that page does exist, and is in the pages folder within my project.

Is there a step I'm missing in converting our package to a SFDX project?

Best Answer

In general, you can successfully grab all the metadata from an org, but there will be difficulty deploying all that metadata to another org. Often you will encounter dependencies and other issues that stop the deployment.

Try to narrow down what you are deploying, or focus on a single package. The force:source:push command has the ability to do exactly this and limit what is being deployed. See:

https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm

Related Topic