npm install -g yo generator-code
yo code
- You need to choose TypeScript for the project.
After running the commands, we already have a VS Code Extension project.
Now, you open this project and run the command to start the extension → only press F5 😁
After that, it will open a new window called Extension Development Host. Here, you can press Ctrl + Shift + P and type "Hello world" to call your extension. This command is defined in the package.json file:
"contributes": {
"commands": [
{
"command": "lazycodet.helloWorld",
"title": "Hello world"
}
]
}
You need the vsce package to publish the package, vsce, short for "Visual Studio Code Extensions", is a command-line tool for packaging, publishing and managing VS Code extensions.
npm install -g @vscode/vsce
To publish the package, you need to create an Azure account because:
Visual Studio Code uses Azure DevOps for its Marketplace services. This means that authentication, hosting, and management of extensions are provided through Azure DevOps.
References: https://code.visualstudio.com/api/working-with-extensions/publishing-extension#publishing-extensions
In package.json add:
"publisher": "lazycodet",
Finally, run the command to publish the package:
vsce publish