Scott Hanselman has a great post on the new remote development feature with Visual Studio Code, and I wondered how this would work with Salesforce DX.
Most of my learning for Salesforce DX has been on my personal MacBook, mostly because my company laptop is heavily restricted. I can run Visual Studio Code from my user space under Windows 10, but all the other developer tooling can’t be installed / has issues.
The awesome thing about the new Remote feature is that I was able to install all the required development tooling to a Ubuntu 18 server that I provisioned on a Microsoft Azure subscription and can now control it with Visual Studio as the client.
Note: Please pay close attention as to where I have specified Client machine (your laptop, whatever) and your Remote Machine (Linux server with all dev tools)
- Step 1: Client machine: Download and run Visual Studio Code Insiders (not available in standard release yet)
- Step 2: Client machine: Install the Remote Development extension into Visual Studio Code Insiders
- Step 4: Client machine: Enable the OpenSSH Client feature for Windows (you may need your Administrator to do this for you one time only)
- Step 5: Remote machine: Setup a Linux machine anywhere accessible to your client machine (I used a Ubuntu image from Azure)
- Step 6: Remote machine: Install the Oracle JDK (This alone is a huge benefit to keep your local machine clean 🙂 )
- Step 7: Remote machine: Install the Salesforce Command Line Interface (CLI)
Great! This is the basic setup, now the tricky bits so please also refer to the Microsoft SSH guidance:
- Step 8: Client machine: Run the remote-ssh: Connect to Host command for your Linux server. Visual Studio Code will setup everything for you.
- Step 9: Client machine: Install the Visual Studio Code Salesforce Extension on the remote machine (obviously not on the Client machine)
- Step 10: Remote machine: Login to your remote machine with a remote desktop session and run a new instance of Visual Studio Code with Salesforce CI integration. Authorize an org with the ‘SFDX: Authorize an Org’ command
- Step 11: Remote machine: Still in Remote desktop, run the following command in the Visual Code terminal: ‘sfdx force:org:display -u vscodeOrg –verbose’ (where vscodeOrg the name of your authorized org. Copy the value of “Sfdx Auth Url” which will be in the format force://PlatformCLI:xxxxxxxx.salesforce.com (Danger: This value will let anyone log into your org without username or password!)
- Step 12: Remote machine: Save this value in a text file in an easy location. eg. /home/MyUser/src/login.txt
- Step 13: Client machine: run the following command in the Visual Studio Code terminal window: ‘sfdx force:auth:sfdxurl:store -f login.txt -s -a vscodeOrg
- Step 14: Client machine: (optional) Setup access to your source control repository in Visual Studio Code. Note that the source code will now be held on the remote machine, not your local machine.
And there you have it. You can no use you local machine as a development client, with all tools needed for Salesforce DX running remotely.
Thoughts & observations:
- The configuration could have been changed to use Docker Containers locally. I didn’t go that route because I’m not convinced my company laptop has the right amount of system resources. It would also be very hard to get Docker Desktop installed.
- Setup is non-trivial. Reading through my steps I can see that this is not something that someone who has only ever used Salesforce would want to configure. If you don’t want to jump through the hoops above then I’d advise waiting for a few months for things to advance some more.
- There is exciting potential for ‘code from anywhere’ with this model. It is probably unrealistic (for example) to have the full Salesforce DX development suite on an Apple iPad, but definitely more realistic to have the Visual Studio Code client running and connecting to a development server in the cloud.