My VSCode extension has a tab, which shows a view (defined in package.json
). Is it possible to show the extension’s installed version number (as listed in package.json
) inside a view?
This is a sample of my code
I included the [installed_package_version]
variable as aim for this question.
"contributes": {
"viewsContainers": {
"activitybar": [
{
"id": "myview",
"title": "My view",
"icon": "icon.png"
}
]
},
"viewsWelcome": [
{
"view": "myview-page",
"contents": "My content. Current version: [installed_package_version]",
"when": "true"
}
],
"views": {
"myview": [
{
"id": "myview-page",
"name": "My view",
"type": "tree"
}
]
}
}
2
Answers
Here’s simple example for how you show vscode extention version in web view:
if this helped?
To display the version number of your VSCode extension inside a view, you can achieve this programmatically rather than directly through the
package.json
configuration. Here’s how you can do it:Here’s a basic example of how you could accomplish this using TypeScript:
This code does the following:
extension.showMyView
to trigger the view.vscode.extensions.getExtension
.You’ll need to replace
'your.extension.identifier'
with the actual identifier of your extension. You can find this in your extension’spackage.json
.Remember to include this in your
package.json
:This way, your view will be shown dynamically with the version information whenever the command is executed.