Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to run vscode extension command just right after installation?

I need to run the extension command right after the installation. There is an event like onStartupFinished, but the problem is, it will run every time the vscode starts.
How to do it? does vsocde have any way to do it?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can use a version field in the global context state. You get the context in your activation method.

export const activate = (context: ExtensionContext): void => {
    const myExtension = extensions.getExtension("<my-extension-id>");
    const currentVersion = msgExtension!.packageJSON.version ?? "1.0.0";

    const lastVersion = context.globalState.get("MyExtensionVersion");
    if (currentVersion !== lastVersion) {
        void context.globalState.update("MyExtensionVersion", currentVersion);
        // Do one time setup here.
    }
}

Don’t forget to set onStartupFinished in activationEvents.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading