Skip to content

Commit 9af6345

Browse files
Create vsce.md
1 parent 3c710b0 commit 9af6345

File tree

1 file changed

+141
-0
lines changed
  • cheatsheets/vscode-extensions

1 file changed

+141
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
---
2+
title: VSCE
3+
description: How to use the vsce command
4+
---
5+
6+
What is VSCE?
7+
8+
> The Visual Studio Code Extension Manager
9+
10+
11+
## Resources
12+
13+
- [vsce cli](https://vscode-docs.readthedocs.io/en/latest/tools/vscecli/) docs
14+
- [vsce](https://www.npmjs.com/package/vsce) package on NPM
15+
- [Publishing extensions](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) in VS Code docs
16+
- [Microsoft/vscode-vsce](https://github.com/Microsoft/vscode-vsce) repo
17+
18+
19+
## CLI
20+
21+
```sh
22+
$ vsce --help
23+
```
24+
```
25+
Usage: vsce <command> [options]
26+
27+
Options:
28+
-V, --version output the version number
29+
-h, --help output usage information
30+
31+
Commands:
32+
ls [options] Lists all the files that will be published
33+
package [options] Packages an extension
34+
publish [options] [<version>] Publishes an extension
35+
unpublish [options] [<extensionid>] Unpublishes an extension. Example extension id: microsoft.csharp.
36+
ls-publishers List all known publishers
37+
create-publisher <publisher> Creates a new publisher
38+
delete-publisher <publisher> Deletes a publisher
39+
login <publisher> Add a publisher to the known publishers list
40+
logout <publisher> Remove a publisher from the known publishers list
41+
show [options] <extensionid> Show extension metadata
42+
search [options] <text> search extension gallery
43+
```
44+
45+
46+
## Commands
47+
48+
Run `vsce` using a global installed, or use `node_modules/bin/vsce` instead of `vsce` below. Run from the project root.
49+
50+
### List
51+
52+
```sh
53+
$ vsce ls
54+
```
55+
56+
### Package
57+
58+
The package and publish steps could be added to `package.json` and also then to a workflow for a release. For now, manually using and also uploading to a release will work. The trick is to do the build _after_ using tagging (e.g. `npm version minor`), to ensure the name of the filename and the contents matches.
59+
60+
61+
```sh
62+
$ vsce package
63+
Executing prepublish script 'npm run vscode:prepublish'...
64+
...
65+
DONE Packaged: /home/michael/repos/auto-commit-msg/auto-commit-msg-0.6.0.vsix (31 files, 33.21KB)
66+
```
67+
68+
Alternatively specify ignored `build` directory. Some may prefer `dist` for distribution.
69+
70+
```sh
71+
$ vsce package --out build
72+
```
73+
74+
Example output name: `auto-commit-msg-0.6.0.vsix`. That will be in the repo root or a given out directory.
75+
76+
77+
```sh
78+
$ vsce package -h
79+
```
80+
```
81+
Usage: package [options]
82+
83+
Packages an extension
84+
85+
Options:
86+
-o, --out [path] Output .vsix extension file to [path] location
87+
--baseContentUrl [url] Prepend all relative links in README.md with this url.
88+
--baseImagesUrl [url] Prepend all relative image links in README.md with this url.
89+
--yarn Use yarn instead of npm
90+
--ignoreFile [path] Indicate alternative .vscodeignore
91+
--noGitHubIssueLinking Prevent automatic expansion of GitHub-style issue syntax into links
92+
-h, --help output usage information
93+
```
94+
95+
### Publish
96+
97+
Some other steps might be needed like `login` and `create-publisher`.
98+
99+
```sh
100+
$ vsce publish
101+
# <publisherID>.myExtension published to VS Code MarketPlace
102+
```
103+
104+
105+
## Install
106+
107+
Extensions must go in `~/.vscode/extensions` according to the docs - that's where other marketplace extensions go as directories.
108+
109+
Run this to unzip your build package and move it to the appropriate directory.
110+
111+
```sh
112+
$ code --install-extension EXTENSION_PATH
113+
```
114+
```
115+
Installing extensions...
116+
Extension 'auto-commit-msg-0.6.0.vsix' was successfully installed.
117+
```
118+
119+
Check it:
120+
121+
```sh
122+
$ ls ~/.vscode/extensions/
123+
```
124+
```
125+
dbaeumer.vscode-eslint-2.1.8 michaelcurrin.auto-commit-msg-0.6.0
126+
```
127+
128+
You can do this while VS Code is running. You can check `@installed` in your extensions tab and it can refresh to show the latest version under the same name. But you might get "Reload Required" notice so it's a good idea to click that or restart VS Code another way.
129+
130+
If published, you can also install by providing the extension ID from the marketplace for the command above.
131+
132+
There is also the `ext` syntax you'll see in the marketplace which can be added to the command bar.
133+
134+
135+
## Notes
136+
137+
The `.vscodeignore` file determines what gets excluded from the package. The `.vsix` file seems implied and not needed to be listed there. Same for `package-lock.json` and `.vscode` directory.
138+
139+
But other dot paths like `.github` and `.gitignore` must be listed in the ignore file. You might want to keep the `docs` and `LICENSE` though.
140+
141+
The `vscode:prepublish` step is set in `package.json`. This is run as part of `vsce package` command.

0 commit comments

Comments
 (0)