I use the Force.com migration tool and git in my daily workflow for Salesforce development and recently tried setting up my local environment on the Linux subsystem that comes with Windows 10.
- Windows 10 with the Linux subsystem (WSL) installed
- Git is already installed in the WSL environment
Step 1: Install Java (JDK)
First update the package index
sudo apt-get update
Then, install the Java Development Kit (JDK)
sudo apt-get install default-jdk
Check that Java is installed
Step 2: Install Ant
Update the package index and install ant
sudo apt-get update sudo apt-get install ant
Check that Ant is installed
Step 3: Add the Force.com Migration Tool
The Force.com Migration Tool is basically a jar file that adds functionality to Ant and enables the ability to retrieve and deploy metadata to/from Salesforce environments.
There are a couple of options for adding the Force.com Migration Tool:
- Download and add the jar file to the directory where Ant is installed. Save the file in the lib folder within the Ant directory. For solo developers or small teams this might be an easy way to get started. The path to that folder in my Linux subsystem is: /usr/share/ant/lib
- Add the jar file to the git repository and specify the location of the jar file in each Ant command. This works well for multi-developer teams. The jar file needs to be updated with each Salesforce release and this is good way to make sure all developers working on a project are using the same version of the metadata API when retrieving and deploying metadata.
Step 4: Create SSH key and add to Git repository
Connecting to a Git repository with an SSH key will remove the need to enter the username and password when connecting to your online repository.
First check for existing SSH keys
If there are existing keys, copy the contents of your public key file
If you see “No such file or directory”, then there aren’t existing keys. Generate a new key
ssh-keygen -t rsa -C "firstname.lastname@example.org"
- Press “Enter” on your keyboard to accept the default location
- Enter a passphrase and re-enter when prompted
In your terminal window, display and then select and copy the contents of your public key file.
Follow the instructions provided by your online git repository to add the SSH key to your account. Below are links to SSH instructions and troubleshooting tips for major online git repositories:
You should be all set to start working with files from a Salesforce environment or a hosted git repository!
Below are a few additional resources you should review and understand before working with the Linux subsystem on Windows.
- Important: Do not change Linux files using Windows apps and tools
- Overview of Bash on Ubuntu on Windows