Detect current VSIX package's version from code

前端 未结 2 2009
隐瞒了意图╮
隐瞒了意图╮ 2021-01-14 14:30

I am writing a VSIX project and I would like for the code to be able to determine whether an update is available.

I know Visual Studio would be able to check for the

2条回答
  •  走了就别回头了
    2021-01-14 14:41

    Nordin's solution seems good, but I just want to mention that there is one more way to get current version of the extension. I have no idea in what situation my solution might be better, maybe if you don't know the path to the manifest on the client that uses this extension.

    // get ExtensionManager
    IVsExtensionManager manager = GetService(typeof(SVsExtensionManager)) as IVsExtensionManager;
    // get your extension by Product Id
    IInstalledExtension myExtension = manager.GetInstalledExtension("ProductId-1234-1234-1234-123456789012");
    // get current version
    Version currentVersion = myExtension.Header.Version;
    

    I call this inside Initialize() method of my package.

提交回复
热议问题