Skip to content

Understanding workspaces

Before you begin creating applications, it is important to understand and distinguish the two types of workspaces that you will encounter while using the extension.

VS Code workspace

VS Code workspace is the collection of one or more folders that are opened together in VS Code with associated settings.

When you open a folder using File > Open Folder..., a single-folder workspace is opened and the workspace settings are stored in the .vscode\settings.json file.

A single-folder workspace opened inside VS Code

If a project's code is distributed across several folders, as in the case of an application and library code, you might need a multi-root workspace. A multi-root workspace is created by adding new folders using File > Add Folders to Workspace.

Multi-root workspace opened inside VS Code

Until saved, the multi-root workspace settings are stored in a temporary file.

Tip

We recommend to always save the multi-root workspace to a .code-workspace file using File > Save Workspace As....

You can quickly check where the workspace settings are stored and the current values using the Preferences: Open Workspace Settings (JSON) command from the Command Palette.

West workspace

West workspace is a collection of folders that are jointly version-controlled using the west management tool. A west workspace is indicated by a .west folder that contains the west workspace configuration.

Typically, when working with Workspace applications, you will open a west workspace as a VS Code workspace.

West workspace opened inside VS Code

Extension settings

The extension stores information such as the nRF Connect SDK version, the nRF Connect SDK toolchain, and the application list in the VS Code workspace settings.

The extension uses built-in and custom variables to replace local system paths while storing the settings. This makes the workspace file suitable for checking in to version control and sharing between developers.

See Additional settings information for more details about variable substitution.

Storing an application and its settings

Based on the type of your current workspace, an application and its settings are saved in one of the following files:

  • For multi-root workspaces: {workspace_name}.code-workspace.json

  • For a single-root workspace: .vscode/settings.json

To learn more about general VS Code workspace mechanisms, see the workspace documentation in the VS Code documentation.

Caution

If you have not saved the current workspace you are working in, then the file containing information about your application and its settings is saved in a temporary location. This temporary file is not meant to be interacted with directly. It is deleted at the end of the session unless you save the workspace. When saving the workspace, you are asked for a location to save it in.

If you have not saved your current workspace but want to recover your applications and their configurations, see the Recovering unsaved changes section of this page.

Handling application settings

Within the workspace options, the nrf-connect.applications setting controls which applications are listed in the Applications View. When a new application location is added to that setting, the extension scans the application directory for build directories and adds them to the Applications View.

Recovering unsaved changes

If you have made changes to your application without saving the workspace settings, they can be restored. VS Code will never remove any of the build configurations on its own. However, as the list of applications in your workspace is stored in the workspace settings, VS Code will lose track of them if you exit without saving. When you reopen the unsaved workspace, your application and build configurations will not appear in the Sidebar.

You can restore an application by creating a new workspace and then adding the application back into the workspace. To do this, click on Add an existing application in the Welcome View, and choose the folder where your application is stored. The application will reappear in the Applications View.

Back to top