Example #1
0
 public void Dispose()
 {
     if (_isMessageFilterRegistered)
     {
         MessageFilter.Revoke();
     }
 }
        public bool TrySetDebuggerOptions(string projectName, string excelExePath, string excelAddInToDebug)
        {
            try
            {
                MessageFilter.Register();

                var project = _dte.GetProjectByName(projectName);
                if (project != null)
                {
                    _log.Debug($"Found project: {project.Name}");
                    var configuration = project
                                        .ConfigurationManager
                                        .ActiveConfiguration;

                    var startAction    = configuration.Properties.Item("StartAction");
                    var startProgram   = configuration.Properties.Item("StartProgram");
                    var startArguments = configuration.Properties.Item("StartArguments");

                    startAction.Value    = 1; // Start external program
                    startProgram.Value   = excelExePath;
                    startArguments.Value = $@"""{Path.GetFileName(excelAddInToDebug)}""";

                    project.Save(string.Empty);

                    return(true);
                }

                return(false);
            }
            finally
            {
                MessageFilter.Revoke();
            }
        }