public void Update(AssemblyInformation assemblyInformation)
        {
            var lines = File.ReadAllLines(_filePath);

            for (var i = 0; i < lines.Length; i++)
            {
                var line = lines[i];
                line     = Regex.Replace(line, CreateSearchPattern(CopyrightAttributeName), CreateReplaceValue(CopyrightAttributeName, assemblyInformation.Copyright));
                line     = Regex.Replace(line, CreateSearchPattern(FileVersionAttributeName), CreateReplaceValue(FileVersionAttributeName, assemblyInformation.Version));
                line     = Regex.Replace(line, CreateSearchPattern(ProductAttributeName), CreateReplaceValue(ProductAttributeName, assemblyInformation.ProductVersion));
                line     = Regex.Replace(line, CreateSearchPattern(VersionAttributeName), CreateReplaceValue(VersionAttributeName, assemblyInformation.Version));
                lines[i] = line;
            }

            File.WriteAllLines(_filePath, lines);
        }
Пример #2
0
        public void Update(AssemblyInformation assemblyInformation)
        {
            var lines = File.ReadAllLines(_filePath, Encoding.Unicode);

            for (var i = 0; i < lines.Length; i++)
            {
                var line = lines[i];
                line     = Regex.Replace(line, CreatePrimarySearchPattern(PrimaryFileVersionAttributeName), CreatePrimaryReplaceValue(PrimaryFileVersionAttributeName, ConvertVersion(assemblyInformation.Version)));
                line     = Regex.Replace(line, CreatePrimarySearchPattern(PrimaryProductAttributeName), CreatePrimaryReplaceValue(PrimaryProductAttributeName, ConvertVersion(assemblyInformation.Version)));
                line     = Regex.Replace(line, CreateSecondarySearchPattern(SecondaryCopyrightAttributeName), CreateSecondaryReplaceValue(SecondaryCopyrightAttributeName, assemblyInformation.Copyright));
                line     = Regex.Replace(line, CreateSecondarySearchPattern(SecondaryFileVersionAttributeName), CreateSecondaryReplaceValue(SecondaryFileVersionAttributeName, assemblyInformation.Version));
                line     = Regex.Replace(line, CreateSecondarySearchPattern(SecondaryProductAttributeName), CreateSecondaryReplaceValue(SecondaryProductAttributeName, assemblyInformation.ProductVersion));
                lines[i] = line;
            }

            File.WriteAllLines(_filePath, lines, Encoding.Unicode);
        }
Пример #3
0
        internal static void Main(string[] args)
        {
            var logger = new Logger($"{DateTime.Now.Ticks}");
            var updateVersionFactory = new UpdateVersionFactory();

            try
            {
                var configuration       = ConfigurationLoader.Load();
                var assemblyInformation = configuration.AssemblyInformation;

                logger.Information("started");
                logger.Information("acquiring last commit id...");

                using (var process = CreateProcess(GetFullPath(configuration.Root, configuration.GetCommitId)))
                {
                    process.Start();
                    process.WaitForExit();

                    var lastCommitId = File.ReadAllText(GetFullPath(configuration.Root, configuration.CommitId)).Trim();
                    assemblyInformation = new AssemblyInformation(assemblyInformation.Version, $"{assemblyInformation.ProductVersion}+{lastCommitId}", assemblyInformation.Copyright);
                    logger.Information($"last commit id: {lastCommitId}");
                }

                logger.Information($"version: {assemblyInformation.Version}, productVersion: {assemblyInformation.ProductVersion}");

                foreach (var relativeFilePath in configuration.Assemblies)
                {
                    var filePath = GetFullPath(configuration.Root, relativeFilePath);

                    updateVersionFactory.Create(filePath)
                    .Update(assemblyInformation);

                    logger.Information($"{filePath} file updated");
                }

                var buildPath = GetFullPath(configuration.Root, configuration.Build);
                logger.Information($"building solution with {buildPath}...");

                using (var process = CreateProcess(buildPath))
                {
                    process.Start();
                    process.WaitForExit();
                    logger.Information("solution built");
                }

                var makePackagePath = GetFullPath(configuration.Root, configuration.MakePackage);
                logger.Information($"making package with {makePackagePath} and copying its content to {assemblyInformation.ProductVersion}");

                using (var process = CreateProcess(makePackagePath, assemblyInformation.ProductVersion))
                {
                    process.Start();
                    process.WaitForExit();
                }

                logger.Information("package made");
            }
            catch (Exception exception)
            {
                logger.Error(exception.ToString());
            }

            logger.Information("stopped");
        }