Пример #1
0
        static int Run(string[] args)
        {
            if (args.Length == 0)
            {
                Console.Error.WriteLine($"No action specified");
                return(1);
            }

            if (!Enum.TryParse(args[0], out BuildAction action))
            {
                Console.Error.WriteLine($"Unknown action '{args[0]}'");
                return(2);
            }

            var actionArgs = new List <string>(args.Skip(1));

            switch (action)
            {
            case BuildAction.Build:
            case BuildAction.Clean:
                var ba = new BuildArguments();
                if (!ba.Parse(actionArgs))
                {
                    return(1);
                }
                if (ba.TargetType == TargetType.Program)
                {
                    return(0);
                }
                foreach (var sln in GetSolutions(ba))
                {
                    if (!MSBuildHelpers.BuildSolution(sln, action.ToString(), action == BuildAction.Build, ba))
                    {
                        return(1);
                    }
                }
                return(0);

            case BuildAction.GenerateProjects:
                var ga = new GenerateProjectsArguments();
                if (!ga.Parse(actionArgs))
                {
                    return(1);
                }
                return(GenerateProjects.Run(ga));

            default:
                Console.Error.WriteLine($"Unsupported action '{action}'");
                return(1);
            }
        }
Пример #2
0
        public static bool BuildSolution(string sln, string target, bool restore, BuildArguments args)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("/t:{0}", target);

            sb.AppendFormat(
                " /p:Configuration=\"{0}\" /p:Platform=\"{1}\"",
                ConfigurationHelpers.GetSolutionConfigurationName(args.TargetConfiguration, args.TargetType),
                args.TargetPlatform
                );

            //parallel
            sb.Append(" /m");

            if (restore)
            {
                sb.Append(" /r");
            }

            //less verbose
            sb.Append(" /nologo /v:minimal");

            //output binary log
            if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MONOUE_BINLOG")))
            {
                sb.Append(" /bl");
            }

            sb.AppendFormat(" \"{0}\"", Path.GetFullPath(sln));

            var msbuildExe = GetMSBuildPath(args.PluginDir);

            var process = System.Diagnostics.Process.Start(
                new System.Diagnostics.ProcessStartInfo(msbuildExe, sb.ToString())
            {
                UseShellExecute  = false,
                WorkingDirectory = Path.GetDirectoryName(sln)
            });

            process.WaitForExit();

            if (process.ExitCode > 0)
            {
                Console.Error.WriteLine($"Solution '{sln} failed with code {process.ExitCode}'");
                return(false);
            }

            return(true);
        }
Пример #3
0
        static IEnumerable <string> GetSolutions(BuildArguments args)
        {
            string generatedSolutionFile;
            string appName;

            if (!string.IsNullOrEmpty(args.ProjectFile))
            {
                appName = Path.GetFileNameWithoutExtension(args.ProjectFile);
                generatedSolutionFile = Path.Combine(args.ProjectDir, args.PlatformIntermediateDir, appName, "Mono", appName + "_Bindings.sln");
            }
            else
            {
                appName = "UE4";

                // non-game, UE4 target
                if (!args.AppName.StartsWith("UE4", StringComparison.Ordinal))
                {
                    throw new InvalidOperationException("Expected UE4 target because no uproject file was specified");
                }

                generatedSolutionFile = Path.Combine(args.PluginDir, args.PlatformIntermediateDir, "Mono", "UE4_Bindings.sln");
            }

            if (File.Exists(generatedSolutionFile))
            {
                yield return(generatedSolutionFile);
            }

            // see if we're building a managed game
            if (string.IsNullOrEmpty(args.ProjectFile) || !args.AppName.StartsWith(appName, StringComparison.Ordinal))
            {
                yield break;
            }

            // See if there is a managed solution to build
            var managedSolutionPath = Path.Combine(args.ProjectDir, appName + "_Managed.sln");

            if (File.Exists(managedSolutionPath))
            {
                yield return(managedSolutionPath);
            }
        }