The "SFDX: Deploy Code to org" command uses the sfdx force:source:deploy command, which according to the documentation only deploys to non-production orgs (at least as of Spring '19).
A nifty way to deploy to production with these new commands (as inspired by the documentation above) is as follows:
- Set the
SFDX_MDAPI_TEMP_DIRenvironment variable to a place that's easily accessible (like themetadatafolder within your current project):
SFDX_MDAPI_TEMP_DIR=/path/to/mydxproject/metadata - Retrieve the exact metadata you want to deploy to production, like as follows:
sfdx force:source:retrieve -m ApexClass:MyUtilClass,ApexClass:MyUtilClass_Test -u MySandboxOrg - This will create a folder within your
metadatafolder with the metadata .zip file or package.xml file that you're looking for. Deploy from the zip file as follows (and feel free to add any other helpful options as specified in the mdapi Commands):
sfdx force:mdapi:deploy -f ./metadata/sdx_sourceRetrieve_1554058974901/unpackaged.zip -u MyProductionOrg -w 3 - CheckIf the deployment takes longer than three minutes (as specified in the above
-w 3flag), then check your deployment status in the production org itself or viamdapi:deploy:report:
sfdx force:mdapi:deploy:report -u MyProductionOrg This allows you to use the new force:source:retrieve command and have it auto-convert into metadata, without having to call force:source:convert manually