3

I want to check the version of the currently installed VSPackage to notify the users if his version is outdated. I don't want to upload my extension (yet), so I can't use the built-in update feature.

How can I read the version of my extension that is specified in the vsixmanifest file?

flayn
  • 5,272
  • 4
  • 48
  • 69
  • @michaelrmcneill: no duplicate! I want the version of my installed VSPackage and not the version of Visual Studio! – flayn Jul 13 '14 at 16:43
  • @SimonMourier: I know how I can read/edit/view it in Visual Studio. I would like to know how to read the version when the extension is running. Similar to http://stackoverflow.com/questions/11082436/detect-the-visual-studio-version-inside-a-vspackage?rq=1 but not the Visual Studio version. – flayn Jul 14 '14 at 11:51

1 Answers1

2

You could use a function like this:

    public static Version GetExecutingAssemblyVersion()
    {
        var ver = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);

        // read what's defined in [assembly: AssemblyFileVersion("1.2.3.4")]
        return new Version(ver.ProductMajorPart, ver.ProductMinorPart, ver.ProductBuildPart, ver.ProductPrivatePart);
    }
Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • The VSPackage is executed inside Visual Studio. Your code will only give me the Visual Studio version. – flayn Jul 14 '14 at 14:06
  • Have you tested it? Assembly.GetExecutingAssembly gets the assembly that contains the code that is currently executing. – Simon Mourier Jul 14 '14 at 16:39
  • I stand corrected! But this gives me the DLL version and not the version I specified in the vsixmanifest file. – flayn Jul 14 '14 at 18:52
  • You should state what you want exactly (the Vsix manifest version) in your question, like I asked initially. – Simon Mourier Jul 16 '14 at 13:08