LazyCodet

a

09:58:56 5/5/2025 - 1 views -
Programming

Create a VS Code Extension

Create project

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"
		}
	]
}

Publish package

​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.

  • ​Installing the package:
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

  • ​Follow the docs above, you create an Azure account and an organization → create a token
  • ​Create a publisher (ex, My publisher is lazycodet)

​In package.json add:

"publisher": "lazycodet",

​Finally, run the command to publish the package:

vsce publish