
Adding Recommended Extensions to a Multi-Root VS Code Workspace
Many of you likely work in an environment where you're not the only developer. So, how do you get every developer to use the same extensions in VS Code?
I suggest you start by reading the official documentation
regarding recommended extensions. If you are like me and have a .code-workspace
multi-root workspace file already being used by your team, you can
leverage that file by adding a bit more to the JSON data. Assume the following starting example:
{
"folders": [
{
"name": "platform",
"path": "platform"
},
{
"name": "client",
"path": "client"
},
{
"name": "logs",
"path": "logs"
}
]
}
We have a build tool that spins up instances of our product and one of the steps is to write this .code-workspace
file to the developer's machine
so it can easily be opened and have all the Git tools in VS Code pick up that there are two different repositories (one for platform
and one
for client
). That's why we needed a multi-root workspace in the first place.
Now, on to adding the recommended extensions, which in our case is only going to be the EditorConfig
extension. The official documentation says you can list the extensions under extensions.recommendations
. My primitive brain first went to
assuming that they meant something like this, even though a little voice in the back of my head was telling me it wouldn't work:
{
"extensions.recommendations": [
]
}
I tried to verify that the extensions are recommended by opening the command palette and using the "Extensions: Show Recommended Extensions" option.
To my chagrin, it didn't work. I did notice another option in the command palette:
It might be labeled slightly different in reality. The screenshot was not generated while using a multi-root workspace.
I clicked on the "Configure Recommended Extensions" option and it added this to my .code-workspace
file:
{
"extensions": {
"recommendations": [
]
}
}
I knew I should have paid heed to that little voice. Here's what I ended up going with to add the EditorConfig extension as a recommended extension for all of my colleagues:
{
"folders": [
{
"name": "platform",
"path": "platform"
},
{
"name": "client",
"path": "client"
},
{
"name": "logs",
"path": "logs"
}
],
"extensions": {
"recommendations": [
"editorconfig.editorconfig"
]
}
}
Now whenever my colleagues open this same workspace and don't have the EditorConfig extension added, they will be prompted to install it.