VSXtra for VS 2010 and 2012?

Sep 3, 2012 at 5:20 AM

Hi,

I'm just starting to learn VS extensibility and came across this great project that can make my life a lot easier. Is there any way I can use it to develop extensions for VS 2010 and 2012?

Jul 30, 2013 at 5:11 AM
You have to modify SiteManager to make it work.
The VSMoniker strings in original SiteManager is hard coded, and it includes only VS9 and VS10. VS2012's version is VS11, so you need to add a moniker string to VSMonikers list.
I tried another way to get moniker dynamically by query Registry, and it works fine.
        // --------------------------------------------------------------------------------------------
        /// <summary>
        /// Monikers of possible DTE objects. Right now VS 2008 and VS 2010 is handled.
        /// </summary>
        // --------------------------------------------------------------------------------------------
        private static readonly IEnumerable<string> VSMonikers;

        // --------------------------------------------------------------------------------------------
        /// <summary>
        /// The static constructor automatically tries to assign the SiteManager static class to a site
        /// that accesses VS IDE global services.
        /// </summary>
        // --------------------------------------------------------------------------------------------
        static SiteManager()
        {
            var vsRegKey = Registry.CurrentUser
                .OpenSubKey("Software")
                .OpenSubKey("Microsoft")
                .OpenSubKey("VisualStudio");
            var installedNames = vsRegKey.GetSubKeyNames().Where(x => !x.Contains("Exp") && !x.Contains("_Config"));
            VSMonikers = installedNames.Select(x => "!VisualStudio.DTE." + x + ":{0}").ToArray();

            foreach (string moniker in VSMonikers)
            {
                TryToGetServiceProviderFromCurrentProcess(moniker);
                if (HasGlobalServiceProvider) return;
            }
        }