Example #1
0
        private int RunGitVersionTool(GitVersionOptions gitVersionOptions)
        {
            try
            {
                var variables = gitVersionTool.CalculateVersionVariables();

                gitVersionTool.OutputVariables(variables);
                gitVersionTool.UpdateAssemblyInfo(variables);
                gitVersionTool.UpdateWixVersionFile(variables);

                execCommand.Execute(variables);
            }
            catch (WarningException exception)
            {
                var error = $"An error occurred:{System.Environment.NewLine}{exception.Message}";
                log.Warning(error);
                return(1);
            }
            catch (Exception exception)
            {
                var error = $"An unexpected error occurred:{System.Environment.NewLine}{exception}";
                log.Error(error);

                if (gitVersionOptions == null)
                {
                    return(1);
                }

                log.Info("Attempting to show the current git graph (please include in issue): ");
                log.Info("Showing max of 100 commits");

                try
                {
                    LibGitExtensions.DumpGraph(gitVersionOptions.WorkingDirectory, mess => log.Info(mess), 100);
                }
                catch (Exception dumpGraphException)
                {
                    log.Error("Couldn't dump the git graph due to the following error: " + dumpGraphException);
                }
                return(1);
            }

            return(0);
        }
        public void UpdateAssemblyInfo(UpdateAssemblyInfo task)
        {
            FileHelper.DeleteTempFiles();
            if (task.CompileFiles != null)
            {
                FileHelper.CheckForInvalidFiles(task.CompileFiles, task.ProjectFile);
            }

            var fileWriteInfo = task.IntermediateOutputPath.GetFileWriteInfo(task.Language, task.ProjectFile, "AssemblyInfo");

            task.AssemblyInfoTempFilePath = Path.Combine(fileWriteInfo.WorkingDirectory, fileWriteInfo.FileName);

            var arguments = options.Value;

            arguments.UpdateAssemblyInfo = true;
            arguments.EnsureAssemblyInfo = true;
            arguments.TargetPath         = fileWriteInfo.WorkingDirectory;
            arguments.AddAssemblyInfoFileName(fileWriteInfo.FileName);
            gitVersionTool.UpdateAssemblyInfo(versionVariables);
        }