Exemple #1
0
        public static string GetMsbuildFilePath()
        {
            string[] MsBuildPathArray =
            {
                "\\MSBuild\\Current\\Bin\\MSBuild.exe",
                "\\MSBuild\\15.0\\Bin\\MSBuild.exe"
            };
            string vswhere = string.Empty;

            if (Environment.Is64BitOperatingSystem)
            {
                vswhere = Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer\\vswhere.exe");
            }
            else
            {
                vswhere = Environment.ExpandEnvironmentVariables("%ProgramFiles%\\Microsoft Visual Studio\\Installer\\vswhere.exe");
            }

            // Note: vswere.exe was only released with build 15.0.26418.1
            if (File.Exists(vswhere))
            {
                string vswhereResult = Win32.ShellExecute(vswhere,
                                                          "-latest " +
                                                          "-prerelease " +
                                                          "-products * " +
                                                          "-requires Microsoft.Component.MSBuild " +
                                                          "-property installationPath "
                                                          );

                if (string.IsNullOrEmpty(vswhereResult))
                {
                    return(null);
                }

                foreach (string path in MsBuildPathArray)
                {
                    if (File.Exists(vswhereResult + path))
                    {
                        return(vswhereResult + path);
                    }
                }

                return(null);
            }
            else
            {
                try
                {
                    VisualStudioInstance instance = FindVisualStudioInstance();

                    if (instance != null)
                    {
                        foreach (string path in MsBuildPathArray)
                        {
                            if (File.Exists(instance.Path + path))
                            {
                                return(instance.Path + path);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Program.PrintColorMessage("[VisualStudioInstance] " + ex, ConsoleColor.Red, true);
                }

                return(null);
            }
        }
Exemple #2
0
 static AppVeyor()
 {
     AppVeyorPath = Win32.SearchFile("appveyor.exe");
 }
Exemple #3
0
        public static void Main(string[] args)
        {
            ProgramArgs = ParseArgs(args);

            if (ProgramArgs.ContainsKey("-cleanup"))
            {
                if (Restart("-cleanup"))
                {
                    return;
                }

                if (!Build.InitializeBuildEnvironment(true))
                {
                    return;
                }

                Build.CleanupAppxSignature();
                Build.CleanupBuildEnvironment();

                Build.ShowBuildStats();
            }
            else if (ProgramArgs.ContainsKey("-phapppub_gen"))
            {
                if (!Build.InitializeBuildEnvironment(false))
                {
                    return;
                }

                Build.BuildPublicHeaderFiles();
            }
            else if (ProgramArgs.ContainsKey("-graph"))
            {
                if (!Build.InitializeBuildEnvironment(true))
                {
                    return;
                }

                Build.ShowBuildEnvironment("changelog", true, false);

                if (Win32.GetConsoleMode(Win32.GetStdHandle(Win32.STD_OUTPUT_HANDLE), out ConsoleMode mode))
                {
                    Win32.SetConsoleMode(Win32.GetStdHandle(Win32.STD_OUTPUT_HANDLE), mode | ConsoleMode.ENABLE_VIRTUAL_TERMINAL_PROCESSING);
                }

                Console.WriteLine(Build.GetBuildLogString());

                Build.ShowBuildStats();
            }
            else if (ProgramArgs.ContainsKey("-sdk"))
            {
                if (!Build.InitializeBuildEnvironment(false))
                {
                    return;
                }

                Build.CopyKProcessHacker(
                    BuildFlags.Build32bit | BuildFlags.Build64bit |
                    BuildFlags.BuildDebug
                    );

                BuildSdk(
                    BuildFlags.Build32bit | BuildFlags.Build64bit |
                    BuildFlags.BuildDebug | BuildFlags.BuildVerbose
                    );
            }
            else if (ProgramArgs.ContainsKey("-cleansdk"))
            {
                if (!Build.InitializeBuildEnvironment(false))
                {
                    return;
                }

                if (!Build.BuildSolution("ProcessHacker.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildVerbose | BuildFlags.BuildApi
                                         ))
                {
                    return;
                }

                BuildSdk(BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildVerbose);

                Build.ShowBuildStats();
            }
            else if (ProgramArgs.ContainsKey("-bin"))
            {
                if (!Build.InitializeBuildEnvironment(false))
                {
                    return;
                }

                Build.ShowBuildEnvironment("bin", false, true);
                Build.CopyKeyFiles();

                if (!Build.BuildSolution("ProcessHacker.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildVerbose | BuildFlags.BuildApi
                                         ))
                {
                    return;
                }

                if (!Build.CopyKProcessHacker(
                        BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildVerbose))
                {
                    return;
                }

                if (!BuildSdk(BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildVerbose))
                {
                    return;
                }

                if (!Build.BuildSolution("plugins\\Plugins.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildVerbose | BuildFlags.BuildApi
                                         ))
                {
                    return;
                }

                if (!Build.CopyWow64Files(BuildFlags.None))
                {
                    return;
                }

                if (!Build.BuildBinZip())
                {
                    return;
                }

                Build.ShowBuildStats();
            }
            else if (ProgramArgs.ContainsKey("-debug"))
            {
                if (!Build.InitializeBuildEnvironment(true))
                {
                    return;
                }

                Build.ShowBuildEnvironment("debug", true, true);
                Build.CopyKeyFiles();

                if (!Build.BuildSolution("ProcessHacker.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildDebug | BuildFlags.BuildVerbose |
                                         BuildFlags.BuildApi
                                         ))
                {
                    return;
                }

                if (!Build.CopyKProcessHacker(
                        BuildFlags.Build32bit | BuildFlags.Build64bit |
                        BuildFlags.BuildDebug | BuildFlags.BuildVerbose))
                {
                    return;
                }

                if (!BuildSdk(
                        BuildFlags.Build32bit | BuildFlags.Build64bit |
                        BuildFlags.BuildDebug | BuildFlags.BuildVerbose
                        ))
                {
                    return;
                }

                if (!Build.BuildSolution("plugins\\Plugins.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildDebug | BuildFlags.BuildVerbose |
                                         BuildFlags.BuildApi
                                         ))
                {
                    return;
                }

                if (!Build.CopyWow64Files(BuildFlags.BuildDebug))
                {
                    return;
                }

                Build.ShowBuildStats();
            }
            else if (ProgramArgs.ContainsKey("-appveyor"))
            {
                if (!Build.InitializeBuildEnvironment(true))
                {
                    Environment.Exit(1);
                }

                Build.ShowBuildEnvironment("nightly", true, true);
                Build.CopyKeyFiles();

                if (!Build.BuildSolution("ProcessHacker.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildVerbose | BuildFlags.BuildApi
                                         ))
                {
                    Environment.Exit(1);
                }

                if (!Build.CopyKProcessHacker(BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildVerbose))
                {
                    Environment.Exit(1);
                }

                if (!BuildSdk(BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildVerbose))
                {
                    Environment.Exit(1);
                }

                if (!Build.BuildSolution("plugins\\Plugins.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildVerbose | BuildFlags.BuildApi
                                         ))
                {
                    Environment.Exit(1);
                }

                if (!Build.CopyWow64Files(BuildFlags.None))
                {
                    Environment.Exit(1);
                }

                if (!Build.BuildBinZip())
                {
                    Environment.Exit(1);
                }
                if (!Build.BuildPdbZip())
                {
                    Environment.Exit(1);
                }
                //if (!Build.BuildWebSetupExe())
                //    Environment.Exit(1);
                if (!Build.BuildSetupExe())
                {
                    Environment.Exit(1);
                }

                if (!Build.BuildChecksumsFile())
                {
                    Environment.Exit(1);
                }
                if (!Build.BuildUpdateSignature())
                {
                    Environment.Exit(1);
                }

                if (!Build.AppveyorUploadBuildFiles())
                {
                    Environment.Exit(1);
                }

                Build.WebServiceUpdateConfig();
            }
            else if (ProgramArgs.ContainsKey("-appxbuild"))
            {
                if (!Build.InitializeBuildEnvironment(true))
                {
                    return;
                }

                Build.ShowBuildEnvironment("appx", true, true);
                Build.CopyKeyFiles();

                if (!Build.BuildSolution("ProcessHacker.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildVerbose | BuildFlags.BuildApi
                                         ))
                {
                    return;
                }

                if (!BuildSdk(BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildVerbose))
                {
                    return;
                }

                if (!Build.BuildSolution("plugins\\Plugins.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildVerbose | BuildFlags.BuildApi
                                         ))
                {
                    return;
                }

                if (!Build.CopyWow64Files(BuildFlags.None))
                {
                    return;
                }

                Build.BuildAppxPackage(BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildVerbose);

                Build.ShowBuildStats();
            }
            else if (ProgramArgs.ContainsKey("-appxmakecert"))
            {
                if (Restart("-appxmakecert"))
                {
                    return;
                }

                if (!Build.InitializeBuildEnvironment(false))
                {
                    return;
                }

                Build.ShowBuildEnvironment("appxcert", true, true);

                Build.BuildAppxSignature();

                Build.ShowBuildStats();
            }
            else
            {
                if (!Build.InitializeBuildEnvironment(true))
                {
                    return;
                }

                Build.ShowBuildEnvironment("release", true, true);
                Build.CopyKeyFiles();

                if (!Build.BuildSolution("ProcessHacker.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildVerbose | BuildFlags.BuildApi
                                         ))
                {
                    return;
                }

                if (!Build.CopyKProcessHacker(BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildVerbose))
                {
                    return;
                }

                if (!BuildSdk(BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildVerbose))
                {
                    return;
                }

                if (!Build.BuildSolution("plugins\\Plugins.sln",
                                         BuildFlags.Build32bit | BuildFlags.Build64bit |
                                         BuildFlags.BuildVerbose | BuildFlags.BuildApi
                                         ))
                {
                    return;
                }

                if (!Build.CopyWow64Files(BuildFlags.None))
                {
                    return;
                }

                if (!Build.BuildBinZip())
                {
                    return;
                }
                if (!Build.BuildSetupExe())
                {
                    return;
                }
                Build.BuildPdbZip();
                Build.BuildSdkZip();
                Build.BuildSrcZip();

                Build.ShowBuildStats();
            }
        }