Detect current VSIX package's version from code

前端 未结 2 2010
隐瞒了意图╮
隐瞒了意图╮ 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:53

    I found that I could read the version information directly from the manifest XML file.

            var doc = new XmlDocument();
            doc.Load(manifestPath);
            var metaData = doc.DocumentElement.ChildNodes.Cast().First(x => x.Name == "Metadata");
            var identity = metaData.ChildNodes.Cast().First(x => x.Name == "Identity");
            var version = identity.GetAttribute("Version");
    

    I also wrote a gist C# class code that encapsulate the code above. Besides, version, this technique could be used to get other information provided by the manifest file.

提交回复
热议问题