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.
The activation event for Salesforce's official extension is it looks for the file sfdx-project.json
file in the workspace. Hence make sure you have the sfdx-project.json
in the project workspace root folder.
Also, make sure you have .sfdx
folder and also have an sfdx-config.json file with defaultusername
set.
Also, try to reload the project using the reload command in command Palette. If the issue still persists feel free to post what your project structure looks like.
NOTE: The official extension has got better since I wrote the answer. It now has all the features that were missing and was supplemented by my extension.
Also yes I created another extension because the official extension has few issues that they are trying to figure still
1.Performance issues for saving single files. You can easily compare that what I have today is at least 2X faster than what you get from the official extension.
This is because they use Metadata API even for single file deploy which as per salesforce has performance issues and they plan to fix it in an upcoming release.
2.The package.xml generation is easier using changesets or unmanaged package container and the official extension does not offer a good GUI to generate them.
3.Official extension uses apex lang server for auto-completion that almost consumes a lot of my CPU. I would rather not have autocompleted than an extension trying to consume my whole CPU.
4.Official salesforce extension does not manage conflict with the server for Nonscratch orgs like sandboxes. It's in their roadmap.
5.Salesforce recommends using the new source format which I too recommend however if you are finding issues with that format the extension I have supports both DX typed source format and traditional source format.
Overall the idea of me building an extension was not to replace Salesforce's official extension instead supplement it with some missing capabilities till salesforce figures all of them.
Best Answer
As of Now
You can use
sfdx force:source:deploy -l RunLocalTests ...
to run tests. This will enable deploying source-formatted metadata directly to production.Original Answer
As of Spring '19
force:source:deploy
doesn't support deploying to production, as it always specifies to run no tests, and tests are required for deployment to production. You can either use unlocked packagesforce:package:install
, or you can useforce:source:convert
followed byforce:mdapi:deploy
to deploy to production.Note to future visitors: This feature may have been added after this answer was written. Be sure to check the documentation.