Пример #1
0
        private static void GenerateVersionConfigFile()
        {
            Console.WriteLine("Warning: this will overwrite the current version " +
                              "configuration, including the build version information. Press " +
                              "ENTER to continue.");
            Console.ReadLine();

            VersionConfig versionConfig = new VersionConfig();

            string[] files = Directory.GetFiles(Environment.CurrentDirectory, "*", SearchOption.AllDirectories);

            foreach (string file in files)
            {
                string relativePath = file.Substring(Environment.CurrentDirectory.Length + 1);

                if (relativePath.StartsWith(BUILD_DIRECTORY))
                {
                    continue;
                }

                if (relativePath == EXE_NAME + ".pdb")
                {
                    continue;
                }

                if (relativePath == Process.GetCurrentProcess().MainModule.FileName.Substring(
                        Environment.CurrentDirectory.Length + 1) ||
                    relativePath == "Rampastring.Updater.dll" ||
                    relativePath == VersionConfig.VERSIONCONFIG_INI ||
                    relativePath == "LocalVersion")
                {
                    continue;
                }

                Console.WriteLine("Including " + relativePath);
                versionConfig.FileEntries.Add(new FileEntry(relativePath, false));
            }

            versionConfig.BuildDirectory   = BUILD_DIRECTORY;
            versionConfig.DisplayedVersion = "Undefined version";
            versionConfig.Write();

            Console.WriteLine();
            Console.WriteLine("Configuration generation finished.");
        }
Пример #2
0
        private static void GenerateBuild()
        {
            char dsc = Path.DirectorySeparatorChar;

            Console.WriteLine("Reading configuration...");
            VersionConfig versionConfig = new VersionConfig();

            versionConfig.Parse();

            Console.WriteLine("Gathering list of outdated files in the build directory...");
            List <FileEntry> filesToProcess = versionConfig.GetOutdatedFileList();

            Directory.CreateDirectory(Environment.CurrentDirectory + dsc + versionConfig.BuildDirectory);

            foreach (FileEntry fileEntry in filesToProcess)
            {
                string filePath         = Environment.CurrentDirectory + dsc + versionConfig.BuildDirectory + dsc + fileEntry.FilePath;
                string originalFilePath = Environment.CurrentDirectory + dsc + fileEntry.FilePath;

                if (!File.Exists(originalFilePath))
                {
                    Console.WriteLine($"Warning: file {fileEntry.FilePath} included in version configuration does not exist. Press ENTER to continue.");
                    Console.ReadLine();
                    continue;
                }

                Directory.CreateDirectory(Path.GetDirectoryName(filePath));

                if (!fileEntry.Compressed)
                {
                    Console.WriteLine("Copying " + fileEntry.FilePath);
                    File.Copy(originalFilePath, filePath, true);
                }
                else
                {
                    Console.WriteLine("Compressing " + fileEntry.FilePath);
                    CompressionHelper.CompressFile(originalFilePath, filePath + RemoteFileInfo.COMPRESSED_FILE_EXTENSION);
                }
            }

            Console.WriteLine("Generating new version files...");

            if (incrementVersion)
            {
                versionConfig.InternalVersion++;
            }

            if (generateVersionFromDate)
            {
                versionConfig.GenerateVersionDisplayStringFromCurrentDate();
            }

            versionConfig.WriteVersionFiles();

            Console.WriteLine("Cleaning build directory from potential leftover files...");
            versionConfig.CleanBuildDirectory();

            Console.WriteLine("Refreshing version configuration...");
            versionConfig.Write();

            Console.WriteLine();

            Console.WriteLine("List of modified files:");
            Console.ForegroundColor = ConsoleColor.Green;

            foreach (FileEntry fileEntry in filesToProcess)
            {
                Console.WriteLine(fileEntry.FilePath);
            }
        }