Пример #1
0
        // #1 copy release folder
        // #2 delete all json settings from release folder
        // #3 get versions from launcher and app (they must be equal)
        // #4 append version to app folder
        // #5 copy assets (EULA,...)
        // #6 create NSIS template '_files_to_pack\nsis'
        static void Main(string[] args)
        {
            try
            {
                var randomPart    = DateTime.UtcNow.Millisecond;
                var tmpWorkFolder = $"tmp_{randomPart}";

                // #1
                // assume we are in installer folder
                var nhmReleaseFolder = GetRootPath(@"..\", "Release");
                ExecXCopy(nhmReleaseFolder, GetRootPath(tmpWorkFolder, "Release"));
                // run the plugins packer in the installer
                Console.WriteLine("ExecPluginsPacker START");
                Console.WriteLine();
                Console.WriteLine();
                ExecPluginsPacker(GetRootPath("MinerPluginsPacker.exe"), GetRootPath(tmpWorkFolder, "Release"), GetRootPath(@"..\", "src", "Miners"));
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("ExecPluginsPacker Done. Press any key to continue");
                Console.ReadKey();

                // #2
                DeleteFileIfExists(GetRootPath(tmpWorkFolder, "Release", "build_settings.json"));

                // #3
                var launcherPath = GetRootPath(tmpWorkFolder, "Release", "NiceHashMiner.exe");
                var appPath      = GetRootPath(tmpWorkFolder, "Release", "app", "app_nhm.exe");
                var(generatedTemplateLauncher, versionLauncher, buildTagLauncher) = VersionInfoHelpers.GenerateVariableTemplate(launcherPath);
                var(generatedTemplate, version, buildTag) = VersionInfoHelpers.GenerateVariableTemplate(appPath);
                if (generatedTemplateLauncher != generatedTemplate || versionLauncher != version || buildTagLauncher != buildTag)
                {
                    throw new Exception("Launcher and App TAG or Version missmatch!!!");
                }
                Console.WriteLine("ExecPluginsPacker resumming...");
                // #4
                var appDirOld = GetRootPath(tmpWorkFolder, "Release", "app");
                var appDirNew = GetRootPath(tmpWorkFolder, "Release", $"app_{version}");
                Console.WriteLine($"moving '{appDirOld}' to '{appDirNew}'");
                Directory.Move(appDirOld, appDirNew);
                // #5
                ZipFile.ExtractToDirectory(GetRootPath("EULA.zip"), GetRootPath(tmpWorkFolder, "Release"));
                // #6
                var filesToPackPath = GetRootPath(tmpWorkFolder, "_files_to_pack");
                RecreateFolderIfExists(filesToPackPath);
                // copy template and exe files
                ExecXCopy(GetRootPath(tmpWorkFolder, "Release"), Path.Combine(filesToPackPath, "bins"));
                ExecXCopy(GetRootPath("nsis_template"), Path.Combine(filesToPackPath, "nsis"));
                File.WriteAllText(Path.Combine(filesToPackPath, "nsis", "include_common", "packageDefsGenerated.nsh"), generatedTemplate, new UTF8Encoding(true));
                File.WriteAllText(Path.Combine(filesToPackPath, "version.txt"), version + buildTag);
                // delete previous _files_to_pack from nhmpacker
                var nhmPackerFilesToPack = GetRootPath("nhmpacker", "_files_to_pack");
                RecreateFolderIfExists(nhmPackerFilesToPack);
                ExecXCopy(filesToPackPath, nhmPackerFilesToPack);
                RecreateFolderIfExists(GetRootPath("nhmpacker", "_files_to_pack", "assets")); // just so the packer works
                ExecNhmpackerCreateInstallers(GetRootPath("nhmpacker", "nhmpacker.exe"));
                File.Move(GetRootPath("nhmpacker", $"nhm_windows_{version}.exe"), GetRootPath(tmpWorkFolder, $"nhm_windows_{version}.exe"));
                File.Move(GetRootPath("nhmpacker", $"nhm_windows_updater_{version}.exe"), GetRootPath(tmpWorkFolder, $"nhm_windows_updater_{version}.exe"));
                // move to the temp folder

                // nhm_windows_1.9.2.18_testnetdev.zip
                // nhm_windows_1.9.2.18_testnet.zip
                // TODO create these settings instead of copying them
                var buildSettings = new List <BuildTag> {
                    BuildTag.PRODUCTION, BuildTag.TESTNET, BuildTag.TESTNETDEV
                };
                foreach (var build in buildSettings)
                {
                    DeleteFileIfExists(GetRootPath(tmpWorkFolder, "Release", "build_settings.json"));
                    var zipFileName = $"nhm_windows_{version}";
                    if (build != BuildTag.PRODUCTION)
                    {
                        zipFileName += $"_{build.ToString().ToLower()}";
                        File.Copy(GetRootPath("build_settings", $"build_settings_{build.ToString()}.json"), GetRootPath(tmpWorkFolder, "Release", "build_settings.json"), true);
                    }
                    Console.WriteLine($"Creating {zipFileName}.zip package");
                    ZipFile.CreateFromDirectory(GetRootPath(tmpWorkFolder, "Release"), GetRootPath(tmpWorkFolder, $"{zipFileName}.zip"));
                    Console.WriteLine($"FINISHED {zipFileName}.zip package");
                }

                Console.WriteLine("Clean up temp files...");
                //Console.ReadKey();
                Directory.Delete(GetRootPath(tmpWorkFolder, "_files_to_pack"), true);
                Directory.Delete(GetRootPath(tmpWorkFolder, "Release"), true);
                Console.WriteLine("Finishing...");
                Directory.Move(GetRootPath(tmpWorkFolder), GetRootPath($"nhm_windows_{version}_release_files"));
                Console.WriteLine("DONE!");
                Console.ReadKey();
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine($"\t\t PROBLEM: {e.Message} {e.Message}");
                Console.WriteLine($"\t\t PROBLEM: {e.StackTrace}");
                Console.ReadKey();
            }
        }
Пример #2
0
        // #1 copy release folder
        // #2 delete all json settings from release folder
        // #3 get versions from launcher and app (they must be equal)
        // #4 append version to app folder
        // #5 copy assets (EULA,...)
        // #6 create NSIS template '_files_to_pack\nsis'
        static async Task Main(string[] args)
        {
            try
            {
                var randomPart    = DateTime.UtcNow.Millisecond;
                var tmpWorkFolder = $"tmp_{randomPart}";
                Logger.ConfigureWithFile(GetRootPath($"{tmpWorkFolder}_log.txt"));
                Logger.ConfigureConsoleLogging(Level.Info);
                // TODO check if this already exists
                SetTemporaryWorkFolder(tmpWorkFolder);
                Add7zToPath();

                // #1
                // assume we are in installer folder
                var nhmReleaseFolder = GetRootPath(@"..\", "Release");
                ExecXCopy(nhmReleaseFolder, GetTemporaryWorkFolder("Release"));

                // run the plugins packer in the installer
                Logger.Info("Main", "MinerPluginsPacker.Execute START");
                MinerPluginsPacker.Execute(GetRootPath(@"..\", "src", "Miners"));
                Logger.Info("Main", "MinerPluginsPacker.Execute DONE. Press any key to continue\n\n");
                Console.ReadKey();

                // run the plugins packer in the installer
                Logger.Info("Main", "PluginPackageBundler.ExecuteTask START");
                await PluginPackageBundler.ExecuteTask(MinerPluginsPacker.PreInstalledPlugins, NHM.MinerPluginToolkitV1.Checkers.SupportedMajorVersions);

                Logger.Info("Main", "PluginPackageBundler.ExecuteTask DONE. Press any key to continue\n\n");
                Console.ReadKey();

                Logger.Info("Main", "Moving 'miner_plugins' and 'plugins_packages' to 'Release'");
                Directory.Move(GetMinerPluginsPath(), GetTemporaryWorkFolder("Release", "miner_plugins"));
                Directory.Move(GetPluginsPackagesPath(), GetTemporaryWorkFolder("Release", "plugins_packages"));

                // #2
                DeletePathIfExists(GetTemporaryWorkFolder("Release", "build_settings.json"));

                // #3
                var(generatedTemplateLauncher, versionLauncher, buildTagLauncher) = VersionInfoHelpers.GenerateVariableTemplate(GetTemporaryWorkFolder("Release", "NiceHashMiner.exe"));
                var(generatedTemplate, version, buildTag) = VersionInfoHelpers.GenerateVariableTemplate(GetTemporaryWorkFolder("Release", "app", "app_nhm.exe"));
                if (generatedTemplateLauncher != generatedTemplate || versionLauncher != version || buildTagLauncher != buildTag)
                {
                    throw new Exception($"Launcher and App TAG or Version missmatch!!!\n{generatedTemplateLauncher} != {generatedTemplate} \n{versionLauncher} != {version} \n{buildTagLauncher} != {buildTag}");
                }
                Logger.Info("Main", "ExecPluginsPacker resumming...");
                // #4
                var appDirOld = GetTemporaryWorkFolder("Release", "app");
                var appDirNew = GetTemporaryWorkFolder("Release", $"app_{version}");
                Logger.Info("Main", $"moving '{appDirOld}' to '{appDirNew}'");
                Directory.Move(appDirOld, appDirNew);
                // #5
                ZipFile.ExtractToDirectory(GetRootPath("EULA.zip"), GetTemporaryWorkFolder("Release"));
                // #6
                var filesToPackPath = GetTemporaryWorkFolder("_files_to_pack");
                RecreateDirectoryIfExists(filesToPackPath);
                // copy template and exe files
                ExecXCopy(GetTemporaryWorkFolder("Release"), Path.Combine(filesToPackPath, "bins"));
                ExecXCopy(GetRootPath("nsis_template"), Path.Combine(filesToPackPath, "nsis"));
                File.WriteAllText(Path.Combine(filesToPackPath, "nsis", "include_common", "packageDefsGenerated.nsh"), generatedTemplate, new UTF8Encoding(true));
                File.WriteAllText(Path.Combine(filesToPackPath, "version.txt"), version + buildTag);
                // delete previous _files_to_pack from nhmpacker
                var nhmPackerFilesToPack = GetRootPath("nhmpacker", "_files_to_pack");
                RecreateDirectoryIfExists(nhmPackerFilesToPack);
                ExecXCopy(filesToPackPath, nhmPackerFilesToPack);
                RecreateDirectoryIfExists(GetRootPath("nhmpacker", "_files_to_pack", "assets")); // just so the packer works
                ExecNhmpackerCreateInstallers(GetRootPath("nhmpacker", "nhmpacker.exe"));
                File.Move(GetRootPath("nhmpacker", $"nhm_windows_{version}.exe"), GetTemporaryWorkFolder($"nhm_windows_{version}.exe"));
                File.Move(GetRootPath("nhmpacker", $"nhm_windows_updater_{version}.exe"), GetTemporaryWorkFolder($"nhm_windows_updater_{version}.exe"));
                // move to the temp folder

                // nhm_windows_1.9.2.18_testnetdev.zip
                // nhm_windows_1.9.2.18_testnet.zip
                // TODO create these settings instead of copying them
                var buildSettings = new List <BuildTag> {
                    BuildTag.PRODUCTION, BuildTag.TESTNET, BuildTag.TESTNETDEV
                };
                foreach (var build in buildSettings)
                {
                    DeletePathIfExists(GetTemporaryWorkFolder("Release", "build_settings.json"));
                    var zipFileName = $"nhm_windows_{version}";
                    if (build != BuildTag.PRODUCTION)
                    {
                        zipFileName += $"_{build.ToString().ToLower()}";
                        File.Copy(GetRootPath("build_settings", $"build_settings_{build}.json"), GetTemporaryWorkFolder("Release", "build_settings.json"), true);
                    }
                    else
                    {
                        var password       = $"nhm{version.Replace(".", "")}";
                        var zipFileNamePwd = $"nhm_windows_{version}_pw.zip";
                        Logger.Info("Main", $"Creating password protected {zipFileNamePwd} package password='******'");
                        Exec7ZipCreatePasswordArchive(password, GetTemporaryWorkFolder(zipFileNamePwd), GetTemporaryWorkFolder("Release"));
                    }
                    Logger.Info("Main", $"Creating {zipFileName}.zip package");
                    ZipFile.CreateFromDirectory(GetTemporaryWorkFolder("Release"), GetTemporaryWorkFolder($"{zipFileName}.zip"));
                    Logger.Info("Main", $"FINISHED {zipFileName}.zip package");
                }

                Logger.Info("Main", "Clean up temp files...");
                Directory.Delete(GetTemporaryWorkFolder("_files_to_pack"), true);
                Directory.Delete(GetTemporaryWorkFolder("Release"), true);
                Logger.Info("Main", "Finishing...");
                CopyInstallerScriptIfAvailable();
                Directory.Move(GetTemporaryWorkFolder(), GetRootPath($"nhm_windows_{version}_release_files"));
                Logger.Info("Main", "DONE! SUCCESS!!! Press any key to continue\n\n");
                Console.ReadKey();
                return;
            }
            catch (Exception e)
            {
                Logger.Error("Main", $"\t\t PROBLEM: {e.Message} {e.Message}");
                Logger.Error("Main", $"\t\t PROBLEM: {e.StackTrace}");
                Logger.Error("Main", "DONE! FAIL!!! Press any key to continue\n\n");
                Console.ReadKey();
            }
        }
Пример #3
0
        // #1 copy release folder
        // #2 delete all json settings from release folder
        // #3 get versions from launcher and app (they must be equal)
        // #4 append version to app folder
        // #5 copy assets (EULA,...)
        // #6 create NSIS template '_files_to_pack\nsis'
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                string tmpWorkFolder2 = "N/A";
                string version2       = "N/A";
                Thread.Sleep(2000);
                try
                {
                    tmpWorkFolder2 = args[0];
                    version2       = args[1];
                    // the final step cannot be done because the ZipFile.CreateFromDirectory locks the folder
                    //RecreateFolderIfExists(GetRootPath($"nhm_windows_{version2}_release_files"));
                    Directory.Delete(GetRootPath(tmpWorkFolder2, "_files_to_pack"), true);
                    Directory.Delete(GetRootPath(tmpWorkFolder2, "Release"), true);
                    Directory.Move(GetRootPath(tmpWorkFolder2), GetRootPath($"nhm_windows_{version2}_release_files"));
                    //ExecXCopy(GetRootPath(tmpWorkFolder), $"nhm_windows_{version}_release_files");
                    return;
                }
                catch (Exception e)
                {
                    Console.WriteLine($"\t\t PROBLEM2: {e.Message}. {tmpWorkFolder2} {version2}");
                    Console.ReadKey();
                }
                return;
            }

            try
            {
                var randomPart    = DateTime.UtcNow.Millisecond;
                var tmpWorkFolder = $"tmp_{randomPart}";

                // #1
                // assume we are in installer folder
                var nhmReleaseFolder = GetRootPath(@"..\", "Release");
                ExecXCopy(nhmReleaseFolder, GetRootPath(tmpWorkFolder, "Release"));
                // run the plugins packer in the installer
                Console.WriteLine("ExecPluginsPacker START");
                Console.WriteLine();
                Console.WriteLine();
                ExecPluginsPacker(GetRootPath("MinerPluginsPacker.exe"), GetRootPath(tmpWorkFolder, "Release"), GetRootPath(@"..\", "src", "Miners"));
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("ExecPluginsPacker Done. Press any key to continue");
                Console.ReadKey();

                // #2
                DeleteFileIfExists(GetRootPath(tmpWorkFolder, "Release", "build_settings.json"));

                // #3
                var launcherPath = GetRootPath(tmpWorkFolder, "Release", "NiceHashMiner.exe");
                var appPath      = GetRootPath(tmpWorkFolder, "Release", "app", "NiceHashMiner.exe");
                var(generatedTemplateLauncher, versionLauncher, buildTagLauncher) = VersionInfoHelpers.GenerateVariableTemplate(launcherPath);
                var(generatedTemplate, version, buildTag) = VersionInfoHelpers.GenerateVariableTemplate(appPath);
                if (generatedTemplateLauncher != generatedTemplate || versionLauncher != version || buildTagLauncher != buildTag)
                {
                    throw new Exception("Launcher and App TAG or Version missmatch!!!");
                }
                // #4
                var appDirOld = GetRootPath(tmpWorkFolder, "Release", "app");
                var appDirNew = GetRootPath(tmpWorkFolder, "Release", $"app_{version}");
                Directory.Move(appDirOld, appDirNew);
                // #5
                File.Copy(GetRootPath("nhm_windows_x.y.z.r-template", "EULA.html"), GetRootPath(tmpWorkFolder, "Release", "EULA.html"));
                File.Copy(GetRootPath("nhm_windows_x.y.z.r-template", "EULA.rtf"), GetRootPath(tmpWorkFolder, "Release", "EULA.rtf"));
                // #6
                var filesToPackPath = GetRootPath(tmpWorkFolder, "_files_to_pack");
                RecreateFolderIfExists(filesToPackPath);
                // copy template and exe files
                ExecXCopy(GetRootPath(tmpWorkFolder, "Release"), Path.Combine(filesToPackPath, "bins"));
                ExecXCopy(GetRootPath("nsis_template"), Path.Combine(filesToPackPath, "nsis"));
                File.WriteAllText(Path.Combine(filesToPackPath, "nsis", "include_common", "packageDefsGenerated.nsh"), generatedTemplate, new UTF8Encoding(true));
                File.WriteAllText(Path.Combine(filesToPackPath, "version.txt"), version + buildTag);
                // delete previous _files_to_pack from nhmpacker
                var nhmPackerFilesToPack = GetRootPath("nhmpacker", "_files_to_pack");
                RecreateFolderIfExists(nhmPackerFilesToPack);
                ExecXCopy(filesToPackPath, nhmPackerFilesToPack);
                RecreateFolderIfExists(GetRootPath("nhmpacker", "_files_to_pack", "assets")); // just so the packer works
                ExecNhmpackerCreateInstallers(GetRootPath("nhmpacker", "nhmpacker.exe"));
                File.Move(GetRootPath("nhmpacker", $"nhm_windows_{version}.exe"), GetRootPath(tmpWorkFolder, $"nhm_windows_{version}.exe"));
                File.Move(GetRootPath("nhmpacker", $"nhm_windows_updater_{version}.exe"), GetRootPath(tmpWorkFolder, $"nhm_windows_updater_{version}.exe"));
                // move to the temp folder

                // nhm_windows_1.9.2.18_testnetdev.zip
                // nhm_windows_1.9.2.18_testnet.zip
                // TODO create these settings instead of copying them
                var buildSettings = new List <BuildTag> {
                    BuildTag.PRODUCTION, BuildTag.TESTNET, BuildTag.TESTNETDEV
                };
                foreach (var build in buildSettings)
                {
                    DeleteFileIfExists(GetRootPath(tmpWorkFolder, "Release", "build_settings.json"));
                    var zipFileName = $"nhm_windows_{version}";
                    if (build != BuildTag.PRODUCTION)
                    {
                        zipFileName += $"_{build.ToString().ToLower()}";
                        File.Copy(GetRootPath("build_settings", $"build_settings_{build.ToString()}.json"), GetRootPath(tmpWorkFolder, "Release", "build_settings.json"), true);
                    }
                    Console.WriteLine($"Creating {zipFileName}.zip package");
                    ZipFile.CreateFromDirectory(GetRootPath(tmpWorkFolder, "Release"), GetRootPath(tmpWorkFolder, $"{zipFileName}.zip"));
                    Console.WriteLine($"FINISHED {zipFileName}.zip package");
                }


                //// the final step cannot be done because the ZipFile.CreateFromDirectory locks the folder FIX RE-RUN PROGRAM
                //Directory.Delete(GetRootPath(tmpWorkFolder, "_files_to_pack"), true);
                //Directory.Delete(GetRootPath(tmpWorkFolder, "Release"), true);
                //RecreateFolderIfExists(GetRootPath($"nhm_windows_{version}_release_files"));
                //Directory.Move(GetRootPath(tmpWorkFolder), GetRootPath($"nhm_windows_{version}_release_files"));
                ////ExecXCopy(GetRootPath(tmpWorkFolder), $"nhm_windows_{version}_release_files");
                var finishProcess = new Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        FileName         = Assembly.GetExecutingAssembly().Location,
                        WorkingDirectory = GetRootPath(),
                        Arguments        = $"{tmpWorkFolder} {version}",
                        WindowStyle      = ProcessWindowStyle.Normal
                    }
                };
                finishProcess.Start();
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine($"\t\t PROBLEM: {e.Message}");
                Console.ReadKey();
            }
        }