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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












5














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
















5














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














5












5








5


1





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

386




386







  • 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











1 Answer
1






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










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

























1 Answer
1






active

oldest

votes








1 Answer
1






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















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













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

249k11191426




249k11191426











  • 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
















  • 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















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

















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

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)