How to push code to production with Visual Studio Code & DX





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







7















I am using Visual Studio Code to develop new functionality.



However, after completing the testing in the sandbox, I want to push the code to production. When I choose "SFDX: Deploy Code to org", it fails with errors -



INVALID_OPERATION: rollbackOnError option must be true on a production org


and



INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations


The code is in the new "source format", but I'm not developing in scratch orgs (I started the project with "SFDX: Create Project with Manifest").



Question 1: Do I need to convert the source to Metadata API format before I can deploy to production? This is not how the instructions in release notes are written:




To deploy source to an org without source tracking (to an org that’s
not a scratch org), right-click a manifest, a source file, or a
directory in the Visual Studio Code explorer. Select SFDX: Deploy
Source to Org.



https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_vscode_any_org.htm




However, the Salesforce DX Developer Guide seems to imply it:




Release Your App to Production



After you convert from source format to metadata format, and package metadata from one org, you can release your app in a different org.



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




Question 2: If I don't need to convert the source format and can push to production directly, how do I set up Visual Studio Code / CLI to avoid the two errors?










share|improve this question




















  • 1





    ...As a programmer, hearing that you push something to production directly from your IDE fills me with sadness. blog.codinghorror.com/the-f5-key-is-not-a-build-process

    – jpmc26
    Dec 29 '18 at 3:40




















7















I am using Visual Studio Code to develop new functionality.



However, after completing the testing in the sandbox, I want to push the code to production. When I choose "SFDX: Deploy Code to org", it fails with errors -



INVALID_OPERATION: rollbackOnError option must be true on a production org


and



INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations


The code is in the new "source format", but I'm not developing in scratch orgs (I started the project with "SFDX: Create Project with Manifest").



Question 1: Do I need to convert the source to Metadata API format before I can deploy to production? This is not how the instructions in release notes are written:




To deploy source to an org without source tracking (to an org that’s
not a scratch org), right-click a manifest, a source file, or a
directory in the Visual Studio Code explorer. Select SFDX: Deploy
Source to Org.



https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_vscode_any_org.htm




However, the Salesforce DX Developer Guide seems to imply it:




Release Your App to Production



After you convert from source format to metadata format, and package metadata from one org, you can release your app in a different org.



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




Question 2: If I don't need to convert the source format and can push to production directly, how do I set up Visual Studio Code / CLI to avoid the two errors?










share|improve this question




















  • 1





    ...As a programmer, hearing that you push something to production directly from your IDE fills me with sadness. blog.codinghorror.com/the-f5-key-is-not-a-build-process

    – jpmc26
    Dec 29 '18 at 3:40
















7












7








7


2






I am using Visual Studio Code to develop new functionality.



However, after completing the testing in the sandbox, I want to push the code to production. When I choose "SFDX: Deploy Code to org", it fails with errors -



INVALID_OPERATION: rollbackOnError option must be true on a production org


and



INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations


The code is in the new "source format", but I'm not developing in scratch orgs (I started the project with "SFDX: Create Project with Manifest").



Question 1: Do I need to convert the source to Metadata API format before I can deploy to production? This is not how the instructions in release notes are written:




To deploy source to an org without source tracking (to an org that’s
not a scratch org), right-click a manifest, a source file, or a
directory in the Visual Studio Code explorer. Select SFDX: Deploy
Source to Org.



https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_vscode_any_org.htm




However, the Salesforce DX Developer Guide seems to imply it:




Release Your App to Production



After you convert from source format to metadata format, and package metadata from one org, you can release your app in a different org.



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




Question 2: If I don't need to convert the source format and can push to production directly, how do I set up Visual Studio Code / CLI to avoid the two errors?










share|improve this question
















I am using Visual Studio Code to develop new functionality.



However, after completing the testing in the sandbox, I want to push the code to production. When I choose "SFDX: Deploy Code to org", it fails with errors -



INVALID_OPERATION: rollbackOnError option must be true on a production org


and



INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations


The code is in the new "source format", but I'm not developing in scratch orgs (I started the project with "SFDX: Create Project with Manifest").



Question 1: Do I need to convert the source to Metadata API format before I can deploy to production? This is not how the instructions in release notes are written:




To deploy source to an org without source tracking (to an org that’s
not a scratch org), right-click a manifest, a source file, or a
directory in the Visual Studio Code explorer. Select SFDX: Deploy
Source to Org.



https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_vscode_any_org.htm




However, the Salesforce DX Developer Guide seems to imply it:




Release Your App to Production



After you convert from source format to metadata format, and package metadata from one org, you can release your app in a different org.



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




Question 2: If I don't need to convert the source format and can push to production directly, how do I set up Visual Studio Code / CLI to avoid the two errors?







deployment metadata-api salesforcedx salesforcedx-cli vs-code






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 29 '18 at 16:28









Peter Mortensen

24317




24317










asked Dec 28 '18 at 19:09









t0tlt0tl

488




488








  • 1





    ...As a programmer, hearing that you push something to production directly from your IDE fills me with sadness. blog.codinghorror.com/the-f5-key-is-not-a-build-process

    – jpmc26
    Dec 29 '18 at 3:40
















  • 1





    ...As a programmer, hearing that you push something to production directly from your IDE fills me with sadness. blog.codinghorror.com/the-f5-key-is-not-a-build-process

    – jpmc26
    Dec 29 '18 at 3:40










1




1





...As a programmer, hearing that you push something to production directly from your IDE fills me with sadness. blog.codinghorror.com/the-f5-key-is-not-a-build-process

– jpmc26
Dec 29 '18 at 3:40







...As a programmer, hearing that you push something to production directly from your IDE fills me with sadness. blog.codinghorror.com/the-f5-key-is-not-a-build-process

– jpmc26
Dec 29 '18 at 3:40












2 Answers
2






active

oldest

votes


















5














You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange package. Otherwise, you would need to use force:source:convert to get a mdapi style format, then use force:mdapi:deploy with the relevant test level (e.g. RunLocalTests) and set rollbackOnError to true. Check out the Salesforce CLI Reference for specific details, or sfdx help force:<command> for command-level help direct from the console. I do not believe that you're currently allowed to create unlocked packages directly via the GUI, but you can open a terminal by using the Terminal > Create New Terminal option, which will open a sfdx environment by default.






share|improve this answer
























  • Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.

    – t0tl
    Dec 28 '18 at 21:09






  • 2





    @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.

    – sfdcfox
    Dec 28 '18 at 21:10











  • Why does Trailhead make it seem like this is possible with LWCs, see section: Deploy Files To Production Org?

    – Xtremefaith
    Feb 8 at 19:12






  • 2





    @sfdcfox Sorry, I wasn't knocking your answer, I was hoping you had some insight because the trailhead is misleading. Just realized the trailhead is referring to a beta command that is failing cause there is no way I see to set rollbackOnError to true for production. To confirm, converting and then using mdapi:deploy works without test for LWCs

    – Xtremefaith
    Feb 8 at 23:19








  • 1





    @Xtremefaith Thanks for the confirmation. I think they'll get around to it some day, but for now, the recommended path would be unlocked packages if you can afford to use them.

    – sfdcfox
    Feb 8 at 23:43



















1














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:




  1. Set the SFDX_MDAPI_TEMP_DIR environment variable to a place that's easily accessible (like the metadata folder within your current project):


SFDX_MDAPI_TEMP_DIR=/path/to/mydxproject/metadata



  1. 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



  1. This will create a folder within your metadata folder 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



  1. Check your deployment status in the production org itself or via mdapi:deploy:report


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






share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "459"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f244951%2fhow-to-push-code-to-production-with-visual-studio-code-dx%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange package. Otherwise, you would need to use force:source:convert to get a mdapi style format, then use force:mdapi:deploy with the relevant test level (e.g. RunLocalTests) and set rollbackOnError to true. Check out the Salesforce CLI Reference for specific details, or sfdx help force:<command> for command-level help direct from the console. I do not believe that you're currently allowed to create unlocked packages directly via the GUI, but you can open a terminal by using the Terminal > Create New Terminal option, which will open a sfdx environment by default.






    share|improve this answer
























    • Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.

      – t0tl
      Dec 28 '18 at 21:09






    • 2





      @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.

      – sfdcfox
      Dec 28 '18 at 21:10











    • Why does Trailhead make it seem like this is possible with LWCs, see section: Deploy Files To Production Org?

      – Xtremefaith
      Feb 8 at 19:12






    • 2





      @sfdcfox Sorry, I wasn't knocking your answer, I was hoping you had some insight because the trailhead is misleading. Just realized the trailhead is referring to a beta command that is failing cause there is no way I see to set rollbackOnError to true for production. To confirm, converting and then using mdapi:deploy works without test for LWCs

      – Xtremefaith
      Feb 8 at 23:19








    • 1





      @Xtremefaith Thanks for the confirmation. I think they'll get around to it some day, but for now, the recommended path would be unlocked packages if you can afford to use them.

      – sfdcfox
      Feb 8 at 23:43
















    5














    You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange package. Otherwise, you would need to use force:source:convert to get a mdapi style format, then use force:mdapi:deploy with the relevant test level (e.g. RunLocalTests) and set rollbackOnError to true. Check out the Salesforce CLI Reference for specific details, or sfdx help force:<command> for command-level help direct from the console. I do not believe that you're currently allowed to create unlocked packages directly via the GUI, but you can open a terminal by using the Terminal > Create New Terminal option, which will open a sfdx environment by default.






    share|improve this answer
























    • Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.

      – t0tl
      Dec 28 '18 at 21:09






    • 2





      @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.

      – sfdcfox
      Dec 28 '18 at 21:10











    • Why does Trailhead make it seem like this is possible with LWCs, see section: Deploy Files To Production Org?

      – Xtremefaith
      Feb 8 at 19:12






    • 2





      @sfdcfox Sorry, I wasn't knocking your answer, I was hoping you had some insight because the trailhead is misleading. Just realized the trailhead is referring to a beta command that is failing cause there is no way I see to set rollbackOnError to true for production. To confirm, converting and then using mdapi:deploy works without test for LWCs

      – Xtremefaith
      Feb 8 at 23:19








    • 1





      @Xtremefaith Thanks for the confirmation. I think they'll get around to it some day, but for now, the recommended path would be unlocked packages if you can afford to use them.

      – sfdcfox
      Feb 8 at 23:43














    5












    5








    5







    You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange package. Otherwise, you would need to use force:source:convert to get a mdapi style format, then use force:mdapi:deploy with the relevant test level (e.g. RunLocalTests) and set rollbackOnError to true. Check out the Salesforce CLI Reference for specific details, or sfdx help force:<command> for command-level help direct from the console. I do not believe that you're currently allowed to create unlocked packages directly via the GUI, but you can open a terminal by using the Terminal > Create New Terminal option, which will open a sfdx environment by default.






    share|improve this answer













    You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange package. Otherwise, you would need to use force:source:convert to get a mdapi style format, then use force:mdapi:deploy with the relevant test level (e.g. RunLocalTests) and set rollbackOnError to true. Check out the Salesforce CLI Reference for specific details, or sfdx help force:<command> for command-level help direct from the console. I do not believe that you're currently allowed to create unlocked packages directly via the GUI, but you can open a terminal by using the Terminal > Create New Terminal option, which will open a sfdx environment by default.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 28 '18 at 20:00









    sfdcfoxsfdcfox

    266k13212459




    266k13212459













    • Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.

      – t0tl
      Dec 28 '18 at 21:09






    • 2





      @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.

      – sfdcfox
      Dec 28 '18 at 21:10











    • Why does Trailhead make it seem like this is possible with LWCs, see section: Deploy Files To Production Org?

      – Xtremefaith
      Feb 8 at 19:12






    • 2





      @sfdcfox Sorry, I wasn't knocking your answer, I was hoping you had some insight because the trailhead is misleading. Just realized the trailhead is referring to a beta command that is failing cause there is no way I see to set rollbackOnError to true for production. To confirm, converting and then using mdapi:deploy works without test for LWCs

      – Xtremefaith
      Feb 8 at 23:19








    • 1





      @Xtremefaith Thanks for the confirmation. I think they'll get around to it some day, but for now, the recommended path would be unlocked packages if you can afford to use them.

      – sfdcfox
      Feb 8 at 23:43



















    • Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.

      – t0tl
      Dec 28 '18 at 21:09






    • 2





      @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.

      – sfdcfox
      Dec 28 '18 at 21:10











    • Why does Trailhead make it seem like this is possible with LWCs, see section: Deploy Files To Production Org?

      – Xtremefaith
      Feb 8 at 19:12






    • 2





      @sfdcfox Sorry, I wasn't knocking your answer, I was hoping you had some insight because the trailhead is misleading. Just realized the trailhead is referring to a beta command that is failing cause there is no way I see to set rollbackOnError to true for production. To confirm, converting and then using mdapi:deploy works without test for LWCs

      – Xtremefaith
      Feb 8 at 23:19








    • 1





      @Xtremefaith Thanks for the confirmation. I think they'll get around to it some day, but for now, the recommended path would be unlocked packages if you can afford to use them.

      – sfdcfox
      Feb 8 at 23:43

















    Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.

    – t0tl
    Dec 28 '18 at 21:09





    Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.

    – t0tl
    Dec 28 '18 at 21:09




    2




    2





    @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.

    – sfdcfox
    Dec 28 '18 at 21:10





    @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.

    – sfdcfox
    Dec 28 '18 at 21:10













    Why does Trailhead make it seem like this is possible with LWCs, see section: Deploy Files To Production Org?

    – Xtremefaith
    Feb 8 at 19:12





    Why does Trailhead make it seem like this is possible with LWCs, see section: Deploy Files To Production Org?

    – Xtremefaith
    Feb 8 at 19:12




    2




    2





    @sfdcfox Sorry, I wasn't knocking your answer, I was hoping you had some insight because the trailhead is misleading. Just realized the trailhead is referring to a beta command that is failing cause there is no way I see to set rollbackOnError to true for production. To confirm, converting and then using mdapi:deploy works without test for LWCs

    – Xtremefaith
    Feb 8 at 23:19







    @sfdcfox Sorry, I wasn't knocking your answer, I was hoping you had some insight because the trailhead is misleading. Just realized the trailhead is referring to a beta command that is failing cause there is no way I see to set rollbackOnError to true for production. To confirm, converting and then using mdapi:deploy works without test for LWCs

    – Xtremefaith
    Feb 8 at 23:19






    1




    1





    @Xtremefaith Thanks for the confirmation. I think they'll get around to it some day, but for now, the recommended path would be unlocked packages if you can afford to use them.

    – sfdcfox
    Feb 8 at 23:43





    @Xtremefaith Thanks for the confirmation. I think they'll get around to it some day, but for now, the recommended path would be unlocked packages if you can afford to use them.

    – sfdcfox
    Feb 8 at 23:43













    1














    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:




    1. Set the SFDX_MDAPI_TEMP_DIR environment variable to a place that's easily accessible (like the metadata folder within your current project):


    SFDX_MDAPI_TEMP_DIR=/path/to/mydxproject/metadata



    1. 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



    1. This will create a folder within your metadata folder 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



    1. Check your deployment status in the production org itself or via mdapi:deploy:report


    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






    share|improve this answer






























      1














      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:




      1. Set the SFDX_MDAPI_TEMP_DIR environment variable to a place that's easily accessible (like the metadata folder within your current project):


      SFDX_MDAPI_TEMP_DIR=/path/to/mydxproject/metadata



      1. 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



      1. This will create a folder within your metadata folder 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



      1. Check your deployment status in the production org itself or via mdapi:deploy:report


      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






      share|improve this answer




























        1












        1








        1







        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:




        1. Set the SFDX_MDAPI_TEMP_DIR environment variable to a place that's easily accessible (like the metadata folder within your current project):


        SFDX_MDAPI_TEMP_DIR=/path/to/mydxproject/metadata



        1. 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



        1. This will create a folder within your metadata folder 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



        1. Check your deployment status in the production org itself or via mdapi:deploy:report


        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






        share|improve this answer















        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:




        1. Set the SFDX_MDAPI_TEMP_DIR environment variable to a place that's easily accessible (like the metadata folder within your current project):


        SFDX_MDAPI_TEMP_DIR=/path/to/mydxproject/metadata



        1. 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



        1. This will create a folder within your metadata folder 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



        1. Check your deployment status in the production org itself or via mdapi:deploy:report


        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







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 10 at 18:54

























        answered Mar 31 at 19:23









        Brian MillerBrian Miller

        668220




        668220






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Salesforce Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f244951%2fhow-to-push-code-to-production-with-visual-studio-code-dx%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bundesstraße 106

            Verónica Boquete

            Ida-Boy-Ed-Garten