How to use Visual Studio with a codespace (Preview)
Visual Studio has great support for developing in GitHub Codespaces. You can create and connect to a codespace and have the full power of Visual Studio to work on your projects on a remote, hosted environment. Even though your source code and tools are in a codespace and your compilation and debugging is happening in the cloud, your development experience will feel as fast and friction-free as if you were working locally. You can work with a codespace from within Visual Studio 2019 Preview (sign up for the limited public beta).
Note
This article specifically describes using Visual Studio to connect to GitHub Codespaces. You can learn about connecting to a codespace with other clients in the Visual Studio Code or GitHub documentation.
Note
If you don't have Visual Studio 2019 Preview installed already, you can download it from visualstudio.microsoft.com.
Enable Connect to GitHub Codespaces
Connecting to GitHub Codespaces with the Visual Studio 2019 Preview is not enabled by default, so you will first need to enable the Preview Features option.
In Visual Studio 2019 Preview, use the Tools > Options menu item to open the Options dialog.
Under Environment, select Preview Features and check the Connect to GitHub Codespaces preview feature.
You will need to restart Visual Studio for the feature to be available.
Create a codespace
If you don't already have a codespace, you can create one from Visual Studio.
When you launch Visual Studio, the Start Window will show a Connect to a codespace button under "Get started".
Select Connect to a codespace and you will be prompted to sign in to GitHub. You can also create a GitHub account, if you don't already have one.
Once you select Sign in to GitHub, follow the online GitHub sign in workflow.
If you've never created a codespace, you will be prompted to create one.
Under "Codespace details", you need to provide a Repository URL. GitHub Codespaces will clone the specified repository into your codespace when it is created.
You can also modify the Instance type and Suspend after timeout via their dropdowns. Once you have set the codespace details, select the Create and Connect button.
GitHub Codespaces will begin preparing the codespace and open Visual Studio, once the codespace is ready.
The codespace name will appear in the remote indicator in the menu bar.
Start using Visual Studio, just as you would working locally. Things to try:
- Browse source code.
- Select a solution file, and build the solution (Ctrl+Shift+B).
- Set a breakpoint in a source file and press F5 to launch the application in the debugger.
- Make changes and commit them to your repository.
Note
At this time, you can not create GitHub Codespaces for Visual Studio through the GitHub Codespaces portal. You can only create them using Visual Studio.
Connect to a codespace
After you've created your codespace, you can open your codespace directly from Visual Studio.
When you launch Visual Studio, the Start Window will show a Connect to a Codespace button under "Get started".
If you are already in Visual Studio, you can use the File > Connect to a Codespace menu item.
Select Connect to a codespace. You will be prompted to sign in to GitHub, if you haven't already.
You will then see all of your GitHub codespaces, along with their details presented in the right panel.
Any codespaces that cloned an Azure DevOps repository will only be visible here in Visual Studio and not on GitHub's Codespaces page.
Choose a codespace and select the Connect button. If the codespace has been suspended, it will be restarted and Visual Studio will open connected to that codespace.
The codespace name will appear in the remote indicator in the menu bar.
Start using Visual Studio, just as you would working locally. Things to try:
- Browse source code.
- Select a solution file, and build the solution (Ctrl+Shift+B).
- Set a breakpoint in a source file and press F5 to launch the application in the debugger.
- Make changes and commit them to your repository.