コード例 #1
0
        private 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);
        }
コード例 #2
0
        public override bool Execute()
        {
            try
            {
                _log.Debug("Running CreateExcelAddIn MSBuild Task");

                LogDiagnostics();

                RunSanityChecks();

                _dnaFilesToPack = new List <ITaskItem>();
                DnaFilesToPack  = new ITaskItem[0];

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

                _configFilesInProject = GetConfigFilesInProject();
                _common = new BuildTaskCommon(FilesInProject, OutDirectory, FileSuffix32Bit, FileSuffix64Bit);

                var buildItemsForDnaFiles = _common.GetBuildItemsForDnaFiles();

                TryBuildAddInFor32Bit(buildItemsForDnaFiles);

                _log.Information("---", MessageImportance.High);

                TryBuildAddInFor64Bit(buildItemsForDnaFiles);

                DnaFilesToPack = _dnaFilesToPack.ToArray();

                return(true);
            }
            catch (Exception ex)
            {
                _log.Error(ex, ex.Message);
                _log.Error(ex, ex.ToString());
                return(false);
            }
        }