After teakhanirons told me some guy got VitaSDK to work in WSL (which I already knew since WSL is more or less a Linux VM), I decided to also get Visual Studio Code to work with it. Fortunately, Microsoft released all the tools required to make this a fairly simple process !
Note : I got this configuration working after following
dots' tutorial and manually fixing stuff.
This may not be and most likely isn't the best way to configure VSC to do this job, but It Just Works(TM).
FOR NON-WINDOWS USERS, SEE POST 2 !Requirements :
For this tutorial, I will use the Debian WSL distribution since it's the one I always install.
Installing the WSL and the VitaSDK/DolceSDK :
Just follow the instructions on MS' website. If you're not familiar with Linux, install Debian as the distribution. Else, choice is up to you.
Don't forget to
initialize your distro. Choose whatever you want as the UNIX username and a UNIX password you won't forget
(Note that the UNIX password isn't shown when typing it, for security reasons).
Once the distro is ready, install the
VitaSDK /
DolceSDK following the Linux instructions. For the exports, if you don't know how to edit the
.bashrc file, type
nano ~/.bashrc
This will open a text editor. Paste the export information at the end of this file, then
restart the WSL distro.
Setting up Visual Studio Code :
Install
VS Code for Windows then open it.
Click on the
Extensions button on the left sidebar, search for
C/C++ and
Remote - WSL, all made
by Microsoft (as shown underlined), and install them.
After both extensions are installed, it is time to configure everything.
Press
CTRL+SHIFT+P to open the
Command Palette and type
Settings json, and look for
Open Settings (JSON).
Add the following to your
settings.json:
"cmake.buildDirectory": "${workspaceRoot}/build/${buildType}",
"cmake.configureOnOpen": true,
"cmake.cmakePath": "/usr/bin/cmake",
"cmake.generator": "Unix Makefiles"
Be sure to have a proper syntax.
Here's what
settings.json could look like
(I also disabled the telemetry and changed a few other settings, which is optional) :
Now, go into your WSL terminal, and browse to a project's directory, then type
code .
This should install the Visual Studio Code server for WSL, and open a new VSC window.
Go back to the Extensions panel. You should now have two panel :
Local and
WSL - Debian (or whatever distro you chose), with the latter empty.
Click on the
Install in WSL: <distro> button of the C/C++ extension. Search for
CMake and install the
CMake Tools extension (
NOT CMake !)
by Microsoft.
Open the Command Palette again, and type
cmake, and look for
Edit User-Local CMake Kits. You might get a message saying you don't have any kits, click on Accept of whatever the button is. This should then open
cmake-tools-kits.json.
Add the following at the beggining, just after the opening bracket (
[ ) :
Example
cmake-tools-kits.json (not the full file) :
Make sure you saved all the config files. CMake should now be configured.
Look at the bottom left corner of the Window, you should see "No Kits Selected", click on that and change it to "VitaSDK"/"DolceSDK".
You should be able to build now by clicking the "Build:" button in the same bottom bar area, or pressing F7.
If it doesn't work the first time:
- Navigate to the location of the source folder and look inside it.
- Make sure there is no build folder.
- Open the command palette and then type Developer Reload and reload the window
And with luck, it should configure CMake and allow you to build the project.
Setting up Projects :
You will have to do this for every new project !Reminder : to open a new project, open its folder in the WSL terminal and type code .Open the Command Palette and type
C++, then look for
C/C++: Edit Configurations (UI)Add a new configuration called VitaSDK/DolceSDK and set the
compiler path to :
Scroll down and un-collapse
Advanced Settings then look for and set the Browse Path to the following:
This should set up IntelliSense.
Note : You might have to select the VitaSDK/DolceSDK configuration in the bottom right corner of the window.With that, you should now be able to enjoy VS Code for your PS Vita software development.
Note: In case you want to make a new project and VSC doesn't connect to the WSL automatically, open the Command Palette, type
WSL and click
on
Remote-WSL : New WindowOptional : Enabling WSL2
WSL2 is the new revision of WSL. While WSL1 is more like a compatibility layer, WSL2 runs a containerized Linux kernel, hence being more of a VM than WSL1 was. To enable WSL2,
see here.