Beispiel #1
0
        /// <summary>
        /// Returns the path to the Xsp.exe or Xsp2.exe based on the XspExeSelection
        /// </summary>
        public string GetXspExePath(int xspExeSelection)
        {
            RegistryHelper regHlpr = new RegistryHelper();
            string strMonoBasePath;
            string retVal = "";

            if(xspExeSelection > 2 || xspExeSelection < 1)
                throw new Exception("Invalid Xsp.exe selection. Value must be either 1 or 2");

            strMonoBasePath = regHlpr.GetMonoBasePath();

            if(xspExeSelection == 1)
            {
                // Handle when it is Xsp.exe
                retVal = Path.Combine(
                    strMonoBasePath,
                    @"lib\mono\1.0\xsp.exe"
                    );
                if(File.Exists(retVal) == true)
                    return retVal;
                retVal = Path.Combine(
                    strMonoBasePath,
                    @"lib\xsp\1.0\xsp.exe"
                    );
                if(File.Exists(retVal) == true)
                    return retVal;
            }

            if(xspExeSelection == 2)
            {
                // Handle when it is Xsp2.exe
                retVal = Path.Combine(
                    strMonoBasePath,
                    @"lib\mono\2.0\xsp2.exe"
                    );
                if(File.Exists(retVal) == true)
                    return retVal;
                retVal = Path.Combine(
                    strMonoBasePath,
                    @"lib\xsp\2.0\xsp2.exe"
                    );
                if(File.Exists(retVal) == true)
                    return retVal;
            }

            return retVal;
        }
Beispiel #2
0
 private void versionComboBox_Change(CommandBarComboBox Ctrl)
 {
     Mfconsulting.Vsprj2make.RegistryHelper regHlpr = new RegistryHelper();
     regHlpr.SetDefaultClr(versionComboBox.Text);
 }
Beispiel #3
0
        // Run on Mono
        public bool TestInMono()
        {
            // Registry Helper Obj
            Mfconsulting.Vsprj2make.RegistryHelper regH = new RegistryHelper();

            // MonoLaunchHelper
            Mfconsulting.Vsprj2make.MonoLaunchHelper launchHlpr = new MonoLaunchHelper();

            // Web
            bool isWebProject = false;
            string aciveFileSharePath = @"C:\inetpub\wwwroot";
            string startPage = "index.aspx";
            string portForXsp = "8189";

            // Other
            string startUpProject = "";
            string projectOutputFileName = "";
            string projectOutputPathFromBase = "";
            int projectOutputType = 0;
            string projectOutputWorkingDirectory = "";

            EnvDTE.Solution thisSln = _applicationObject.Solution;

            // Run in Mono Process
            System.Diagnostics.ProcessStartInfo procInfo = new ProcessStartInfo();
            System.Diagnostics.Process monoLauncC = new System.Diagnostics.Process();
            monoLauncC.StartInfo = procInfo;

            // Get the Solution's startup project
            for (int propIdx = 1; propIdx <= thisSln.Properties.Count; propIdx++)
            {
                if (thisSln.Properties.Item(propIdx).Name.CompareTo("StartupProject") == 0)
                {
                    startUpProject = thisSln.Properties.Item(propIdx).Value.ToString();
                }
            }

            // Run in Mono
            EnvDTE.Projects projs = thisSln.Projects;
            foreach (EnvDTE.Project proj in projs)
            {
                if (startUpProject.CompareTo(proj.Name) == 0)
                {
                    foreach (EnvDTE.Property prop in proj.Properties)
                    {
                        try
                        {
                            if (prop.Name.CompareTo("ProjectType") == 0)
                            {
                                if (Convert.ToInt32(prop.Value) == 1)
                                {
                                    isWebProject = true;
                                    portForXsp = regH.Port.ToString();
                                }
                            }

                            // Web Root for XSP
                            if (prop.Name.CompareTo("ActiveFileSharePath") == 0)
                            {
                                aciveFileSharePath = prop.Value.ToString();
                            }

                            if (prop.Name.CompareTo("OutputType") == 0)
                            {
                                projectOutputType = Convert.ToInt32(prop.Value);
                            }

                            if (prop.Name.CompareTo("OutputFileName") == 0)
                            {
                                projectOutputFileName = prop.Value.ToString();
                            }

                            if (prop.Name.CompareTo("LocalPath") == 0)
                            {
                                projectOutputWorkingDirectory = prop.Value.ToString();
                            }
                        }
                        catch (System.Runtime.InteropServices.COMException exc)
                        {
                            Trace.WriteLine(String.Format("Error during RunOnMono function call:\n {0}", exc.Message));
                        }
                    }

                    // Active Configuration Properties
                    foreach (EnvDTE.Property prop in proj.ConfigurationManager.ActiveConfiguration.Properties)
                    {
                        // XSP startup page
                        if (prop.Name.CompareTo("StartPage") == 0)
                        {
                            startPage = prop.Value.ToString();
                        }

                        // Output path for non web projects
                        if (prop.Name.CompareTo("OutputPath") == 0)
                        {
                            projectOutputPathFromBase = prop.Value.ToString();
                        }
                    }

                    // If is an Executable and not a DLL or web project
                    // then launch it with monoLaunchC
                    if (isWebProject == false && (projectOutputType == 0 || projectOutputType == 1))
                    {
                        monoLauncC.StartInfo.FileName = launchHlpr.MonoLaunchCPath;
                        monoLauncC.StartInfo.WorkingDirectory = System.IO.Path.Combine(
                            projectOutputWorkingDirectory,
                            projectOutputPathFromBase);
                        monoLauncC.StartInfo.Arguments = projectOutputFileName;

                        monoLauncC.Start();
                        return true;
                    }

                    // Web Project execution and launching of XSP
                    if (isWebProject == true)
                    {
                        string startURL = String.Format(
                            "http://localhost:{0}/{1}",
                            portForXsp,
                            startPage);

                        System.Diagnostics.ProcessStartInfo procInfo1 = new ProcessStartInfo();
                        System.Diagnostics.Process launchStartPage = new System.Diagnostics.Process();
                        launchStartPage.StartInfo = procInfo1;

                        monoLauncC.StartInfo.FileName = launchHlpr.MonoLaunchCPath;
                        monoLauncC.StartInfo.WorkingDirectory = aciveFileSharePath;
                        monoLauncC.StartInfo.Arguments = String.Format(
                            "{0} --root . --port {1} --applications /:.",
                            launchHlpr.GetXspExePath(regH.XspExeSelection),
                            portForXsp
                            );

                        // Actually start XSP
                        monoLauncC.Start();

                        launchStartPage.StartInfo.UseShellExecute = true;
                        launchStartPage.StartInfo.Verb = "open";
                        launchStartPage.StartInfo.FileName = startURL;

                        // Do a little delay so XSP can launch
                        System.Threading.Thread.Sleep(1500);
                        launchStartPage.Start();
                    }
                }
            }

            /*
            string strSLNFile = _applicationObject.Solution.FileName;

            _applicationObject.StatusBar.Clear();
            outputWindowPane.OutputString("--------------------------------------\nCompile and Run in Mono: ");
            outputWindowPane.OutputString(String.Format("Solution: {0}\n", strSLNFile));

            _applicationObject.StatusBar.Text = "Attemp to build in Mono...";
            outputWindowPane.OutputString("\tAttemp to build in Mono...\n");

            // Build for Mono

            _applicationObject.StatusBar.Text = "Launch in Mono...";
            outputWindowPane.OutputString("\tLaunch in Mono...\n");

            // Lanunch in Mono
            */

            return true;
        }
Beispiel #4
0
        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        /// <param term='application'>Root object of the host application.</param>
        /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param term='addInInst'>Object representing this Add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            Mfconsulting.Vsprj2make.RegistryHelper regHlpr = new RegistryHelper();
            string[] monoVersions = regHlpr.GetMonoVersions();

            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;
            int selectedIndexForComboBox = 1;

            OutputWindow outputWindow = (OutputWindow)_applicationObject.Windows.Item(Constants.vsWindowKindOutput).Object;
            outputWindowPane = outputWindow.OutputWindowPanes.Add("Monoaddin Messages");

            if(connectMode == ext_ConnectMode.ext_cm_AfterStartup)
            {
                object []contextGUIDS = new object[] { };
                Commands2 commands = (Commands2)_applicationObject.Commands;
                string toolsMenuName;

                _CommandBars commandBars = (Microsoft.VisualStudio.CommandBars._CommandBars)_applicationObject.CommandBars;
                CommandBar cmdBarMonoBarra;
                CommandBarPopup popMenu;	// Prj2Make popupmenu
                CommandBarPopup popMenu2;	// Explorer Current Project

                try
                {
                    //If you would like to move the command to a different menu, change the word "Tools" to the
                    //  English version of the menu. This code will take the culture, append on the name of the menu
                    //  then add the command to that menu. You can find a list of all the top-level menus in the file
                    //  CommandBar.resx.
                    ResourceManager resourceManager = new ResourceManager("monoaddin.CommandBar", Assembly.GetExecutingAssembly());
                    CultureInfo cultureInfo = new System.Globalization.CultureInfo(_applicationObject.LocaleID);
                    string resourceName = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools");
                    toolsMenuName = resourceManager.GetString(resourceName);
                }
                catch
                {
                    //We tried to find a localized version of the word Tools, but one was not found.
                    //  Default to the en-US word, which may work for the current culture.
                    toolsMenuName = "Tools";
                }

                //Place the command on the tools menu.
                //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
                Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = (
                    (Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];

                //Find the Tools command bar on the MenuBar command bar:
                CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
                CommandBarControls commandBarControls;
                commandBarControls = ((CommandBarPopup)toolsControl).Controls;

                // Create Makefile
                Command command1 = null;
                // Generate MonoDevelop files
                Command command2 = null;
                // Generate a distribution unit
                Command command3 = null;
                // Import MonoDevelop Solutions
                Command command4 = null;
                // Run on Mono
                Command command5 = null;
                // vsprj2make Options
                Command command6 = null;
                // Explore current solution
                Command command7 = null;
                // Explore current Project
                Command command8 = null;

                // ------------- Add Pop-up menu ----------------
                popMenu2 = (CommandBarPopup)commandBarControls.Add(
                    MsoControlType.msoControlPopup,
                    System.Reflection.Missing.Value, // Object ID
                    System.Reflection.Missing.Value, // Object parameters
                    1, // Object before
                    true
                    );

                popMenu2.Caption = "&Windows Explore";

                // ------------- Add Pop-up menu ----------------
                popMenu = (CommandBarPopup)commandBarControls.Add(
                    MsoControlType.msoControlPopup,
                    System.Reflection.Missing.Value, // Object ID
                    System.Reflection.Missing.Value, // Object parameters
                    1, // Object before
                    true
                    );

                popMenu.Caption = "Prj&2Make";

                //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in,
                //  just make sure you also update the QueryStatus/Exec method to include the new command names.
                try
                {
                    // Add the create makefile command -- command1
                    //command1 = commands.AddNamedCommand2(
                    //    _addInInstance, "CreateMake", "Create &Makefile",
                    //    "Generate Makefile", true, 59, ref contextGUIDS,
                    //    (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                    //    (int)vsCommandStyle.vsCommandStylePictAndText,
                    //    vsCommandControlType.vsCommandControlTypeButton
                    //);

                    // Add the create makefile command -- command1
                    command1 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "CreateMake",
                        "Create &Makefile",
                        "Generate Makefile",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command1 == null) && (popMenu != null))
                    {
                        command1 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.CreateMake");
                        command1.AddControl(popMenu.CommandBar, 1);
                    }

                }
                catch (System.ArgumentException exc)
                {
                    //If we are here, then the exception is probably because a command with that name
                    //  already exists. If so there is no need to recreate the command and we can
                    //  safely ignore the exception.
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the GenMDFiles command -- command2
                    command2 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "GenMDFiles",
                        "Create Mono&Develop Solution",
                        "Generate MonoDevelop Solution",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command2 == null) && (popMenu != null))
                    {
                        command2 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.GenMDFiles");
                        command2.AddControl(popMenu.CommandBar, 2);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the generate a dist unit command -- command3
                    command3 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "GenDistUnit",
                        "Generate Distribution &Unit",
                        "Generates a distribution unit (zip file)",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command3 == null) && (popMenu != null))
                    {
                        command3 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.GenDistUnit");
                        command3.AddControl(popMenu.CommandBar, 3);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the ImportMD Solution command -- command4
                    command4 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "PrjxToCsproj",
                        "&Import MonoDevelop Solution...",
                        "Imports a MonoDevelop Solution",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command4 == null) && (popMenu != null))
                    {
                        command4 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.PrjxToCsproj");
                        command4.AddControl(popMenu.CommandBar, 4);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the Run on Mono command -- command5
                    command5 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "RunOnMono",
                        "&Run on Mono",
                        "Run solution on mono",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command5 == null) && (popMenu != null))
                    {
                        command5 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.RunOnMono");
                        command5.AddControl(popMenu.CommandBar, 5);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the Options command -- command6
                    command6 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "Options",
                        "&Options...",
                        "Options for prj2make Add-in",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command6 == null) && (popMenu != null))
                    {
                        command6 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.Options");
                        command6.AddControl(popMenu.CommandBar, 6);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the ExploreCurrSln command -- command7
                    command7 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "ExploreCurrSln",
                        "Current &Solution",
                        "Explore the current solution",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command7 == null) && (popMenu != null))
                    {
                        command7 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.ExploreCurrSln");
                        command7.AddControl(popMenu2.CommandBar, 1);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the ExploreCurrDoc command -- command8
                    command8 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "ExploreCurrDoc",
                        "Current &Document",
                        "Explore the current Document",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command8 == null) && (popMenu != null))
                    {
                        command8 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.ExploreCurrDoc");
                        command8.AddControl(popMenu2.CommandBar, 2);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                // Mono Toolbar
                CommandBar cmdBarBuild = (CommandBar)commandBars["Build"];

                try
                {
                    cmdBarMonoBarra = (CommandBar)commandBars["MonoBarra"];
                }
                catch (Exception)
                {
                    commands.AddCommandBar("MonoBarra",
                        vsCommandBarType.vsCommandBarTypeToolbar,
                        cmdBarBuild,
                        1
                        );

                    cmdBarMonoBarra = (CommandBar)commandBars["MonoBarra"];
                    cmdBarMonoBarra.Visible = true;
                }

                if (testInMonoCommandBarButton == null)
                {

                    // Create the Run on Mono Button
                    testInMonoCommandBarButton = (CommandBarButton)cmdBarMonoBarra.Controls.Add(
                        Microsoft.VisualStudio.CommandBars.MsoControlType.msoControlButton,
                        System.Reflection.Missing.Value,
                        System.Reflection.Missing.Value,
                        1,
                        false
                        );

                    testInMonoCommandBarButton.Caption = "Run on &Mono";
                    testInMonoCommandBarButton.DescriptionText = "Run solution with the mono runtime";
                    testInMonoCommandBarButton.TooltipText = "Run on mono";
                    testInMonoCommandBarButton.ShortcutText = "Run on &Mono";
                    testInMonoCommandBarButton.Style = MsoButtonStyle.msoButtonCaption;
                    testInMonoCommandBarButton.Click += new _CommandBarButtonEvents_ClickEventHandler(testInMonoCommandBarButton_Click);
                }

                if (versionComboBox == null)
                {

                    // Create the combobox
                    versionComboBox = (CommandBarComboBox)cmdBarMonoBarra.Controls.Add(
                        Microsoft.VisualStudio.CommandBars.MsoControlType.msoControlDropdown,
                        System.Reflection.Missing.Value,
                        System.Reflection.Missing.Value,
                        2,
                        false
                        );

                    for (int i = 0; i < monoVersions.Length; i++)
                    {
                        versionComboBox.AddItem(monoVersions[i], i + 1);
                        if (monoVersions[i].CompareTo(regHlpr.GetDefaultClr()) == 0)
                        {
                            selectedIndexForComboBox = i + 1;
                        }
                    }

                    versionComboBox.Change += new _CommandBarComboBoxEvents_ChangeEventHandler(versionComboBox_Change);

                    // Select the active index based on
                    // the current mono version
                    versionComboBox.ListIndex = selectedIndexForComboBox;
                }
            }
        }
Beispiel #5
0
        // Generate a distribution unit
        public bool GenerateDistUnit()
        {
            // Create Distribution Unit
            Mfconsulting.Vsprj2make.RegistryHelper regH = new RegistryHelper();
            CreateZipHelper zipObj = new CreateZipHelper();
            string strSLNFile = _applicationObject.Solution.FileName;
            string strIgDirs;
            string strIgEx;
            int nLevel;

            // Get Regvalues
            strIgDirs = regH.IgnoredDirectories;
            strIgEx = regH.IgnoredExtensions;
            nLevel = regH.CompressionLevel;

            _applicationObject.StatusBar.Clear();
            outputWindowPane.OutputString("--------------------------------------\nGenerating a distribution unit for ");
            outputWindowPane.OutputString(String.Format("Solution: {0}\n", strSLNFile));

            _applicationObject.StatusBar.Text = "Creating Zip file...";
            outputWindowPane.OutputString("\tCreating Zip file...\n");

            outputWindowPane.OutputString(zipObj.CreateZipFile(
                strSLNFile,
                strIgDirs,
                strIgEx,
                nLevel
                )
                );

            _applicationObject.StatusBar.Text = "Zip file created!";
            outputWindowPane.OutputString("\tZip file created!\n");

            return true;
        }
Beispiel #6
0
        protected bool IsPrj2MakeAvailable()
        {
            string baseDirectory;
            string strMonoBasePath;
            string strTmp;
            RegistryHelper regH = null;

            try
            {
                regH = new RegistryHelper();

                // This acts as a test to see if mono is installed
                strMonoBasePath = regH.GetMonoBasePath();
                System.Reflection.Assembly myAddIn = System.Reflection.Assembly.GetCallingAssembly();
                baseDirectory = System.IO.Path.GetDirectoryName(myAddIn.Location);
                strTmp = System.IO.Path.Combine(baseDirectory, "prj2makesharpWin32.exe");
                m_strPrj2makePath = (System.IO.File.Exists(strTmp) == true) ? strTmp : null;
                if(m_strPrj2makePath != null)
                    return true;
            }
            catch(Exception)
            {
                m_strPrj2makePath = null;
                return false;
            }
            return false;
        }
Beispiel #7
0
        /// <summary>
        ///      Implements the OnConnection method of the IDTExtensibility2 interface.
        ///      Receives notification that the Add-in is being loaded.
        /// </summary>
        /// <param term='application'>
        ///      Root object of the host application.
        /// </param>
        /// <param term='connectMode'>
        ///      Describes how the Add-in is being loaded.
        /// </param>
        /// <param term='addInInst'>
        ///      Object representing this Add-in.
        /// </param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
        {
            Mfconsulting.Vsprj2make.RegistryHelper regHlpr = new RegistryHelper();
            string []monoVersions = null;

            try
            {
                monoVersions = regHlpr.GetMonoVersions();
            }
            catch(Exception exc)
            {
                // Mono may not be installed
                MessageBox.Show(exc.Message, "Prj2make Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return; // Pull the cord and discontinue loading the add-in
            }

            applicationObject = (_DTE)application;
            addInInstance = (AddIn)addInInst;
            int selectedIndexForComboBox = 1;

            EnvDTE.Events events = applicationObject.Events;
            OutputWindow outputWindow = (OutputWindow)applicationObject.Windows.Item(Constants.vsWindowKindOutput).Object;
            outputWindowPane = outputWindow.OutputWindowPanes.Add("Prj2Make Messages");

            object []contextGUIDS = new object[] { };
            Commands commands = applicationObject.Commands;
            _CommandBars commandBars = applicationObject.CommandBars;
            CommandBar cmdBarMonoBarra;

            CommandBar commandBar = (CommandBar)commandBars["Tools"];
            CommandBarPopup popMenu;	// Prj2Make popupmenu
            CommandBarPopup popMenu2;	// Explorer Current Project

            // Creates a more legible representation of the
            // command bar control collection contained in
            // the Tools command bar
            CommandBarControls commandBarControls;
            commandBarControls = commandBar.Controls;

            // Create Makefile
            Command command1 = null;
            // Generate MonoDevelop files
            Command command2 = null;
            // Import MonoDevelop Solutions
            Command command3 = null;
            // Run on Mono
            Command command5 = null;
            // vsprj2make Options
            Command command6 = null;
            // Generate a distribution unit
            Command command7 = null;
            // Explore current solution
            Command command8 = null;
            // Explore current Project
            Command command9 = null;

            // ------------- Add Pop-up menu ----------------
            popMenu2 = (CommandBarPopup)commandBarControls.Add(
                MsoControlType.msoControlPopup,
                System.Reflection.Missing.Value, // Object ID
                System.Reflection.Missing.Value, // Object parameters
                1, // Object before
                true);

            popMenu2.Caption = "&Windows Explore";

            // ------------- Add Pop-up menu ----------------
            popMenu = (CommandBarPopup)commandBarControls.Add(
                MsoControlType.msoControlPopup,
                System.Reflection.Missing.Value, // Object ID
                System.Reflection.Missing.Value, // Object parameters
                1, // Object before
                true);

            popMenu.Caption = "Prj&2Make";

            // Add the create makefile command -- command1
            command1 = CreateNamedCommand(
                addInInstance,
                commands,
                "CreateMake",
                "Create &Makefile",
                "Generate Makefile",
                ref contextGUIDS
                );

            if(command1 == null)
            {
                command1 = GetExistingNamedCommand(commands, "vsprj2make.Connect.CreateMake");
            }

            try
            {
                command1.AddControl(popMenu.CommandBar, 1);
            }
            catch(System.Exception exc)
            {
                Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
            }

            // Add the generate a dist unit command -- command7
            command7 = CreateNamedCommand(
                addInInstance,
                commands,
                "GenDistUnit",
                "Generate Distribution &Unit",
                "Generates a distribution unit (zip file)",
                ref contextGUIDS
                );

            if(command7 == null)
            {
                command7 = GetExistingNamedCommand(commands, "vsprj2make.Connect.GenDistUnit");
            }

            try
            {
                command7.AddControl(popMenu.CommandBar, 2);
            }
            catch(System.Exception exc)
            {
                Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
            }

            // Add the GenMDFiles command -- command2
            command2 = CreateNamedCommand(
                addInInstance,
                commands,
                "GenMDFiles",
                "Create Mono&Develop Solution",
                "Generate MonoDevelop Solution",
                ref contextGUIDS
                );

            if(command2 == null)
            {
                command2 = GetExistingNamedCommand(commands, "vsprj2make.Connect.GenMDFiles");
            }

            try
            {
                command2.AddControl(popMenu.CommandBar, 3);
            }
            catch(System.Exception exc)
            {
                Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
            }

            // Add the PrjxToCsproj command -- command3
            command3 = CreateNamedCommand(
                addInInstance,
                commands,
                "PrjxToCsproj",
                "&Import MonoDevelop Solution...",
                "Imports a MonoDevelop Solution",
                ref contextGUIDS
                );

            if(command3 == null)
            {
                command3 = GetExistingNamedCommand(commands, "vsprj2make.Connect.PrjxToCsproj");
            }

            try
            {
                command3.AddControl(popMenu.CommandBar, 4);
            }
            catch(System.Exception exc)
            {
                Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
            }

            // Add the Ron on Mono command -- command5
            command5 = CreateNamedCommand(
                addInInstance,
                commands,
                "RunOnMono",
                "&Run on Mono",
                "Run solution on mono",
                ref contextGUIDS
                );

            if(command5 == null)
            {
                command5 = GetExistingNamedCommand(commands, "vsprj2make.Connect.RunOnMono");
            }

            try
            {
                command5.AddControl(popMenu.CommandBar, 5);
            }
            catch(System.Exception exc)
            {
                Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
            }

            // Add the Options command -- command6
            command6 = CreateNamedCommand(
                addInInstance,
                commands,
                "Options",
                "&Options...",
                "Options for prj2make Add-in",
                ref contextGUIDS
                );

            if(command6 == null)
            {
                command6 = GetExistingNamedCommand(commands, "vsprj2make.Connect.Options");
            }

            try
            {
                command6.AddControl(popMenu.CommandBar, 6);
            }
            catch(System.Exception exc)
            {
                Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
            }

            // Add the ExploreCurrSln command -- command8
            command8 = CreateNamedCommand(
                addInInstance,
                commands,
                "ExploreCurrSln",
                "Current &Solution",
                "Explore the current solution",
                ref contextGUIDS
                );

            if(command8 == null)
            {
                command8 = GetExistingNamedCommand(commands, "vsprj2make.Connect.ExploreCurrSln");
            }

            try
            {
                command8.AddControl(popMenu2.CommandBar, 1);
            }
            catch(System.Exception exc)
            {
                Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
            }

            // Add the ExploreCurrDoc command -- command9
            command9 = CreateNamedCommand(
                addInInstance,
                commands,
                "ExploreCurrDoc",
                "Current &Document",
                "Explore the current Document",
                ref contextGUIDS
                );

            if(command9 == null)
            {
                command9 = GetExistingNamedCommand(commands, "vsprj2make.Connect.ExploreCurrDoc");
            }

            try
            {
                command9.AddControl(popMenu2.CommandBar, 2);
            }
            catch(System.Exception exc)
            {
                Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
            }

            // Mono Toolbar
            CommandBar cmdBarBuild = (CommandBar)commandBars["Build"];

            try
            {
                cmdBarMonoBarra = (CommandBar)commandBars["MonoBarra"];
            }
            catch(Exception)
            {
                commands.AddCommandBar("MonoBarra",
                    vsCommandBarType.vsCommandBarTypeToolbar,
                    cmdBarBuild,
                    1
                    );

                cmdBarMonoBarra = (CommandBar)commandBars["MonoBarra"];
                cmdBarMonoBarra.Visible = true;
            }

            if(testInMonoCommandBarButton == null)
            {

                // Create the Ron on Mono Button
                testInMonoCommandBarButton = (CommandBarButton)cmdBarMonoBarra.Controls.Add(
                    Microsoft.Office.Core.MsoControlType.msoControlButton,
                    System.Reflection.Missing.Value,
                    System.Reflection.Missing.Value,
                    1,
                    false
                    );

                testInMonoCommandBarButton.Caption = "Run on &Mono";
                testInMonoCommandBarButton.DescriptionText = "Run solution with the mono runtime";
                testInMonoCommandBarButton.TooltipText = "Run on mono";
                testInMonoCommandBarButton.ShortcutText = "Run on &Mono";
                testInMonoCommandBarButton.Style = MsoButtonStyle.msoButtonCaption;
                testInMonoCommandBarButton.Click +=new _CommandBarButtonEvents_ClickEventHandler(testInMonoCommandBarButton_Click);
            }

            if(versionComboBox == null)
            {

                // Create the combobox
                versionComboBox = (CommandBarComboBox)cmdBarMonoBarra.Controls.Add(
                    Microsoft.Office.Core.MsoControlType.msoControlDropdown,
                    System.Reflection.Missing.Value,
                    System.Reflection.Missing.Value,
                    2,
                    false
                    );

                for(int i = 0; i < monoVersions.Length; i++)
                {
                    versionComboBox.AddItem(monoVersions[i], i + 1);
                    if(monoVersions[i].CompareTo(regHlpr.GetDefaultClr()) == 0)
                    {
                        selectedIndexForComboBox = i + 1;
                    }
                }

                versionComboBox.Change +=new _CommandBarComboBoxEvents_ChangeEventHandler(versionComboBox_Change);

                // Select the active index based on
                // the current mono version
                versionComboBox.ListIndex = selectedIndexForComboBox;
            }
        }
Beispiel #8
0
 private void versionComboBox_Change(CommandBarComboBox Ctrl)
 {
     Mfconsulting.Vsprj2make.RegistryHelper regHlpr = new RegistryHelper();
     regHlpr.SetDefaultClr(versionComboBox.Text);
 }
Beispiel #9
0
        // Run on Mono
        public bool TestInMono()
        {
            // Registry Helper Obj
            Mfconsulting.Vsprj2make.RegistryHelper regH = new RegistryHelper();

            // MonoLaunchHelper
            Mfconsulting.Vsprj2make.MonoLaunchHelper launchHlpr = new MonoLaunchHelper();

            // Web
            bool   isWebProject       = false;
            string aciveFileSharePath = @"C:\inetpub\wwwroot";
            string startPage          = "index.aspx";
            string portForXsp         = "8189";

            // Other
            string startUpProject                = "";
            string projectOutputFileName         = "";
            string projectOutputPathFromBase     = "";
            int    projectOutputType             = 0;
            string projectOutputWorkingDirectory = "";

            EnvDTE.Solution thisSln = _applicationObject.Solution;

            // Run in Mono Process
            System.Diagnostics.ProcessStartInfo procInfo   = new ProcessStartInfo();
            System.Diagnostics.Process          monoLauncC = new System.Diagnostics.Process();
            monoLauncC.StartInfo = procInfo;

            // Get the Solution's startup project
            for (int propIdx = 1; propIdx <= thisSln.Properties.Count; propIdx++)
            {
                if (thisSln.Properties.Item(propIdx).Name.CompareTo("StartupProject") == 0)
                {
                    startUpProject = thisSln.Properties.Item(propIdx).Value.ToString();
                }
            }

            // Run in Mono
            EnvDTE.Projects projs = thisSln.Projects;
            foreach (EnvDTE.Project proj in projs)
            {
                if (startUpProject.CompareTo(proj.Name) == 0)
                {
                    foreach (EnvDTE.Property prop in proj.Properties)
                    {
                        try
                        {
                            if (prop.Name.CompareTo("ProjectType") == 0)
                            {
                                if (Convert.ToInt32(prop.Value) == 1)
                                {
                                    isWebProject = true;
                                    portForXsp   = regH.Port.ToString();
                                }
                            }

                            // Web Root for XSP
                            if (prop.Name.CompareTo("ActiveFileSharePath") == 0)
                            {
                                aciveFileSharePath = prop.Value.ToString();
                            }

                            if (prop.Name.CompareTo("OutputType") == 0)
                            {
                                projectOutputType = Convert.ToInt32(prop.Value);
                            }

                            if (prop.Name.CompareTo("OutputFileName") == 0)
                            {
                                projectOutputFileName = prop.Value.ToString();
                            }

                            if (prop.Name.CompareTo("LocalPath") == 0)
                            {
                                projectOutputWorkingDirectory = prop.Value.ToString();
                            }
                        }
                        catch (System.Runtime.InteropServices.COMException exc)
                        {
                            Trace.WriteLine(String.Format("Error during RunOnMono function call:\n {0}", exc.Message));
                        }
                    }

                    // Active Configuration Properties
                    foreach (EnvDTE.Property prop in proj.ConfigurationManager.ActiveConfiguration.Properties)
                    {
                        // XSP startup page
                        if (prop.Name.CompareTo("StartPage") == 0)
                        {
                            startPage = prop.Value.ToString();
                        }

                        // Output path for non web projects
                        if (prop.Name.CompareTo("OutputPath") == 0)
                        {
                            projectOutputPathFromBase = prop.Value.ToString();
                        }
                    }

                    // If is an Executable and not a DLL or web project
                    // then launch it with monoLaunchC
                    if (isWebProject == false && (projectOutputType == 0 || projectOutputType == 1))
                    {
                        monoLauncC.StartInfo.FileName         = launchHlpr.MonoLaunchCPath;
                        monoLauncC.StartInfo.WorkingDirectory = System.IO.Path.Combine(
                            projectOutputWorkingDirectory,
                            projectOutputPathFromBase);
                        monoLauncC.StartInfo.Arguments = projectOutputFileName;

                        monoLauncC.Start();
                        return(true);
                    }

                    // Web Project execution and launching of XSP
                    if (isWebProject == true)
                    {
                        string startURL = String.Format(
                            "http://localhost:{0}/{1}",
                            portForXsp,
                            startPage);

                        System.Diagnostics.ProcessStartInfo procInfo1       = new ProcessStartInfo();
                        System.Diagnostics.Process          launchStartPage = new System.Diagnostics.Process();
                        launchStartPage.StartInfo = procInfo1;

                        monoLauncC.StartInfo.FileName         = launchHlpr.MonoLaunchCPath;
                        monoLauncC.StartInfo.WorkingDirectory = aciveFileSharePath;
                        monoLauncC.StartInfo.Arguments        = String.Format(
                            "{0} --root . --port {1} --applications /:.",
                            launchHlpr.GetXspExePath(regH.XspExeSelection),
                            portForXsp
                            );


                        // Actually start XSP
                        monoLauncC.Start();

                        launchStartPage.StartInfo.UseShellExecute = true;
                        launchStartPage.StartInfo.Verb            = "open";
                        launchStartPage.StartInfo.FileName        = startURL;

                        // Do a little delay so XSP can launch
                        System.Threading.Thread.Sleep(1500);
                        launchStartPage.Start();
                    }
                }
            }

            /*
             * string strSLNFile = _applicationObject.Solution.FileName;
             *
             * _applicationObject.StatusBar.Clear();
             * outputWindowPane.OutputString("--------------------------------------\nCompile and Run in Mono: ");
             * outputWindowPane.OutputString(String.Format("Solution: {0}\n", strSLNFile));
             *
             * _applicationObject.StatusBar.Text = "Attemp to build in Mono...";
             * outputWindowPane.OutputString("\tAttemp to build in Mono...\n");
             *
             * // Build for Mono
             *
             * _applicationObject.StatusBar.Text = "Launch in Mono...";
             * outputWindowPane.OutputString("\tLaunch in Mono...\n");
             *
             * // Lanunch in Mono
             */

            return(true);
        }
Beispiel #10
0
        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        /// <param term='application'>Root object of the host application.</param>
        /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param term='addInInst'>Object representing this Add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            Mfconsulting.Vsprj2make.RegistryHelper regHlpr = new RegistryHelper();
            string[] monoVersions = regHlpr.GetMonoVersions();

            _applicationObject = (DTE2)application;
            _addInInstance     = (AddIn)addInInst;
            int selectedIndexForComboBox = 1;

            OutputWindow outputWindow = (OutputWindow)_applicationObject.Windows.Item(Constants.vsWindowKindOutput).Object;

            outputWindowPane = outputWindow.OutputWindowPanes.Add("Monoaddin Messages");

            if (connectMode == ext_ConnectMode.ext_cm_AfterStartup)
            {
                object [] contextGUIDS = new object[] { };
                Commands2 commands     = (Commands2)_applicationObject.Commands;
                string    toolsMenuName;

                _CommandBars    commandBars = (Microsoft.VisualStudio.CommandBars._CommandBars)_applicationObject.CommandBars;
                CommandBar      cmdBarMonoBarra;
                CommandBarPopup popMenu;        // Prj2Make popupmenu
                CommandBarPopup popMenu2;       // Explorer Current Project

                try
                {
                    //If you would like to move the command to a different menu, change the word "Tools" to the
                    //  English version of the menu. This code will take the culture, append on the name of the menu
                    //  then add the command to that menu. You can find a list of all the top-level menus in the file
                    //  CommandBar.resx.
                    ResourceManager resourceManager = new ResourceManager("monoaddin.CommandBar", Assembly.GetExecutingAssembly());
                    CultureInfo     cultureInfo     = new System.Globalization.CultureInfo(_applicationObject.LocaleID);
                    string          resourceName    = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools");
                    toolsMenuName = resourceManager.GetString(resourceName);
                }
                catch
                {
                    //We tried to find a localized version of the word Tools, but one was not found.
                    //  Default to the en-US word, which may work for the current culture.
                    toolsMenuName = "Tools";
                }

                //Place the command on the tools menu.
                //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
                Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = (
                    (Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];

                //Find the Tools command bar on the MenuBar command bar:
                CommandBarControl  toolsControl = menuBarCommandBar.Controls[toolsMenuName];
                CommandBarControls commandBarControls;
                commandBarControls = ((CommandBarPopup)toolsControl).Controls;


                // Create Makefile
                Command command1 = null;
                // Generate MonoDevelop files
                Command command2 = null;
                // Generate a distribution unit
                Command command3 = null;
                // Import MonoDevelop Solutions
                Command command4 = null;
                // Run on Mono
                Command command5 = null;
                // vsprj2make Options
                Command command6 = null;
                // Explore current solution
                Command command7 = null;
                // Explore current Project
                Command command8 = null;


                // ------------- Add Pop-up menu ----------------
                popMenu2 = (CommandBarPopup)commandBarControls.Add(
                    MsoControlType.msoControlPopup,
                    System.Reflection.Missing.Value, // Object ID
                    System.Reflection.Missing.Value, // Object parameters
                    1,                               // Object before
                    true
                    );

                popMenu2.Caption = "&Windows Explore";

                // ------------- Add Pop-up menu ----------------
                popMenu = (CommandBarPopup)commandBarControls.Add(
                    MsoControlType.msoControlPopup,
                    System.Reflection.Missing.Value, // Object ID
                    System.Reflection.Missing.Value, // Object parameters
                    1,                               // Object before
                    true
                    );

                popMenu.Caption = "Prj&2Make";

                //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in,
                //  just make sure you also update the QueryStatus/Exec method to include the new command names.
                try
                {
                    // Add the create makefile command -- command1
                    //command1 = commands.AddNamedCommand2(
                    //    _addInInstance, "CreateMake", "Create &Makefile",
                    //    "Generate Makefile", true, 59, ref contextGUIDS,
                    //    (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                    //    (int)vsCommandStyle.vsCommandStylePictAndText,
                    //    vsCommandControlType.vsCommandControlTypeButton
                    //);

                    // Add the create makefile command -- command1
                    command1 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "CreateMake",
                        "Create &Makefile",
                        "Generate Makefile",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command1 == null) && (popMenu != null))
                    {
                        command1 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.CreateMake");
                        command1.AddControl(popMenu.CommandBar, 1);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    //If we are here, then the exception is probably because a command with that name
                    //  already exists. If so there is no need to recreate the command and we can
                    //  safely ignore the exception.
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the GenMDFiles command -- command2
                    command2 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "GenMDFiles",
                        "Create Mono&Develop Solution",
                        "Generate MonoDevelop Solution",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command2 == null) && (popMenu != null))
                    {
                        command2 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.GenMDFiles");
                        command2.AddControl(popMenu.CommandBar, 2);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the generate a dist unit command -- command3
                    command3 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "GenDistUnit",
                        "Generate Distribution &Unit",
                        "Generates a distribution unit (zip file)",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command3 == null) && (popMenu != null))
                    {
                        command3 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.GenDistUnit");
                        command3.AddControl(popMenu.CommandBar, 3);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the ImportMD Solution command -- command4
                    command4 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "PrjxToCsproj",
                        "&Import MonoDevelop Solution...",
                        "Imports a MonoDevelop Solution",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command4 == null) && (popMenu != null))
                    {
                        command4 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.PrjxToCsproj");
                        command4.AddControl(popMenu.CommandBar, 4);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the Run on Mono command -- command5
                    command5 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "RunOnMono",
                        "&Run on Mono",
                        "Run solution on mono",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command5 == null) && (popMenu != null))
                    {
                        command5 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.RunOnMono");
                        command5.AddControl(popMenu.CommandBar, 5);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the Options command -- command6
                    command6 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "Options",
                        "&Options...",
                        "Options for prj2make Add-in",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command6 == null) && (popMenu != null))
                    {
                        command6 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.Options");
                        command6.AddControl(popMenu.CommandBar, 6);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the ExploreCurrSln command -- command7
                    command7 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "ExploreCurrSln",
                        "Current &Solution",
                        "Explore the current solution",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command7 == null) && (popMenu != null))
                    {
                        command7 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.ExploreCurrSln");
                        command7.AddControl(popMenu2.CommandBar, 1);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the ExploreCurrDoc command -- command8
                    command8 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "ExploreCurrDoc",
                        "Current &Document",
                        "Explore the current Document",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command8 == null) && (popMenu != null))
                    {
                        command8 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.ExploreCurrDoc");
                        command8.AddControl(popMenu2.CommandBar, 2);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                // Mono Toolbar
                CommandBar cmdBarBuild = (CommandBar)commandBars["Build"];

                try
                {
                    cmdBarMonoBarra = (CommandBar)commandBars["MonoBarra"];
                }
                catch (Exception)
                {
                    commands.AddCommandBar("MonoBarra",
                                           vsCommandBarType.vsCommandBarTypeToolbar,
                                           cmdBarBuild,
                                           1
                                           );

                    cmdBarMonoBarra         = (CommandBar)commandBars["MonoBarra"];
                    cmdBarMonoBarra.Visible = true;
                }

                if (testInMonoCommandBarButton == null)
                {
                    // Create the Run on Mono Button
                    testInMonoCommandBarButton = (CommandBarButton)cmdBarMonoBarra.Controls.Add(
                        Microsoft.VisualStudio.CommandBars.MsoControlType.msoControlButton,
                        System.Reflection.Missing.Value,
                        System.Reflection.Missing.Value,
                        1,
                        false
                        );

                    testInMonoCommandBarButton.Caption         = "Run on &Mono";
                    testInMonoCommandBarButton.DescriptionText = "Run solution with the mono runtime";
                    testInMonoCommandBarButton.TooltipText     = "Run on mono";
                    testInMonoCommandBarButton.ShortcutText    = "Run on &Mono";
                    testInMonoCommandBarButton.Style           = MsoButtonStyle.msoButtonCaption;
                    testInMonoCommandBarButton.Click          += new _CommandBarButtonEvents_ClickEventHandler(testInMonoCommandBarButton_Click);
                }

                if (versionComboBox == null)
                {
                    // Create the combobox
                    versionComboBox = (CommandBarComboBox)cmdBarMonoBarra.Controls.Add(
                        Microsoft.VisualStudio.CommandBars.MsoControlType.msoControlDropdown,
                        System.Reflection.Missing.Value,
                        System.Reflection.Missing.Value,
                        2,
                        false
                        );

                    for (int i = 0; i < monoVersions.Length; i++)
                    {
                        versionComboBox.AddItem(monoVersions[i], i + 1);
                        if (monoVersions[i].CompareTo(regHlpr.GetDefaultClr()) == 0)
                        {
                            selectedIndexForComboBox = i + 1;
                        }
                    }

                    versionComboBox.Change += new _CommandBarComboBoxEvents_ChangeEventHandler(versionComboBox_Change);

                    // Select the active index based on
                    // the current mono version
                    versionComboBox.ListIndex = selectedIndexForComboBox;
                }
            }
        }