Example #1
0
        public static bool InitializeBuildEnvironment()
        {
            TimeStart      = DateTime.Now;
            GitExePath     = Environment.ExpandEnvironmentVariables("%ProgramFiles%\\Git\\cmd\\git.exe");
            MSBuildExePath = Environment.ExpandEnvironmentVariables(VisualStudio.GetMsbuildFilePath());

            if (!File.Exists(MSBuildExePath))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("MsBuild not installed.\r\nExiting...\r\n");
                Console.ForegroundColor = ConsoleColor.White;
                return(false);
            }

            try
            {
                DirectoryInfo info = new DirectoryInfo(".");

                while (info.Parent != null && info.Parent.Parent != null)
                {
                    info = info.Parent;

                    if (File.Exists(info.FullName + "\\ProcessHacker.sln"))
                    {
                        // Set the root directory.
                        Directory.SetCurrentDirectory(info.FullName);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Error while setting the root directory: " + ex);
                Console.ForegroundColor = ConsoleColor.White;
                return(false);
            }

            if (!File.Exists("ProcessHacker.sln"))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Unable to find project root directory... Exiting.");
                Console.ForegroundColor = ConsoleColor.White;
                return(false);
            }

            if (!File.Exists(GitExePath))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Git not installed... Exiting.");
                Console.ForegroundColor = ConsoleColor.White;
                return(false);
            }

            if (!Directory.Exists(BuildOutputFolder))
            {
                try
                {
                    Directory.CreateDirectory(BuildOutputFolder);
                }
                catch (Exception ex)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Error creating output directory. " + ex);
                    Console.ForegroundColor = ConsoleColor.White;
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
        public static bool InitializeBuildEnvironment(bool CheckDependencies)
        {
            TimeStart      = DateTime.Now;
            GitExePath     = Environment.ExpandEnvironmentVariables("%ProgramFiles%\\Git\\cmd\\git.exe");
            MSBuildExePath = Environment.ExpandEnvironmentVariables(VisualStudio.GetMsbuildFilePath());
            BuildNightly   = !string.Equals(Environment.ExpandEnvironmentVariables("%APPVEYOR_BUILD_API%"), "%APPVEYOR_BUILD_API%", StringComparison.OrdinalIgnoreCase);

            try
            {
                DirectoryInfo info = new DirectoryInfo(".");

                while (info.Parent != null && info.Parent.Parent != null)
                {
                    info = info.Parent;

                    if (File.Exists(info.FullName + "\\ProcessHacker.sln"))
                    {
                        // Set the root directory.
                        Directory.SetCurrentDirectory(info.FullName);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Program.PrintColorMessage("Error while setting the root directory: " + ex, ConsoleColor.Red);
                return(false);
            }

            if (!File.Exists("ProcessHacker.sln"))
            {
                Program.PrintColorMessage("Unable to find project root directory... Exiting.", ConsoleColor.Red);
                return(false);
            }

            if (!File.Exists(MSBuildExePath))
            {
                Program.PrintColorMessage("MsBuild not installed.\r\nExiting...\r\n", ConsoleColor.Red);
                return(false);
            }

            if (CheckDependencies)
            {
                if (!File.Exists(GitExePath))
                {
                    Program.PrintColorMessage("Git not installed... Exiting.", ConsoleColor.Red);
                    return(false);
                }
            }

            if (!Directory.Exists(BuildOutputFolder))
            {
                try
                {
                    Directory.CreateDirectory(BuildOutputFolder);
                }
                catch (Exception ex)
                {
                    Program.PrintColorMessage("Error creating output directory. " + ex, ConsoleColor.Red);
                    return(false);
                }
            }

            return(true);
        }