Пример #1
0
        public override bool Execute()
        {
            try
            {
                _log.Debug("Running SetDebuggerOptions MSBuild Task");

                // Create instances of ExcelDetector and ExcelDnaProject
                _excelDetector = _excelDetectorLazy.Value;
                _project       = _projectLazy.Value;

                FilesInProject = FilesInProject ?? new ITaskItem[0];
                _log.Debug("Number of files in project: " + FilesInProject.Length);

                var excelExePath      = GetExcelPath();
                var addInForDebugging = GetAddInForDebugging(excelExePath);

                LogDiagnostics();

                if (!_project.TrySetDebuggerOptions(ProjectName, excelExePath, addInForDebugging))
                {
                    const string message = "Unable to set the debugger options within Visual Studio. " +
                                           "Please restart Visual Studio and try again.";
                    _log.Warning("DNA" + "PROJECT".GetHashCode(), message);
                }
            }
            catch (Exception ex)
            {
                _log.Warning(ex, ex.Message);
            }

            // Setting the debugger options is not essential to the build process, thus if anything
            // goes wrong, we'll report errors and warnings, but will not fail the build because of that
            return(true);
        }
Пример #2
0
        protected string GetExcelPath()
        {
            var excelExePath = ExcelExePath;

            try
            {
                if (string.IsNullOrWhiteSpace(excelExePath))
                {
                    if (!_excelDetector.TryFindLatestExcel(out excelExePath))
                    {
                        _log.Warning("DNA" + "EXCEL.EXE".GetHashCode(), "Unable to find path where EXCEL.EXE is located");
                        return(excelExePath);
                    }
                }

                if (!File.Exists(excelExePath))
                {
                    _log.Warning("DNA" + "EXCEL.EXE".GetHashCode(),
                                 "EXCEL.EXE not found on disk at location " + excelExePath);
                }
            }
            finally
            {
                _log.Information("EXCEL.EXE path for debugging: " + excelExePath);
            }

            return(excelExePath);
        }
Пример #3
0
 public void Warning(int category, string text, string detail)
 {
     real.Warning(category, text, detail);
 }