Exemple #1
0
        async Task <(bool success, string output)> GetPropertyValue(ProcessRunner runner, string propertyName)
        {
            runner.ClearArguments();
            runner.ClearOutputSinks();
            runner.AddArgument("shell");
            runner.AddArgument("getprop");
            runner.AddArgument(propertyName);

            return(await CaptureAdbOutput(runner));
        }
Exemple #2
0
        void SetGitArguments(ProcessRunner runner, string?workingDirectory, List <string>?gitArguments)
        {
            foreach (string arg in standardGlobalOptions)
            {
                runner.AddArgument(arg);
            }

            if (!String.IsNullOrEmpty(workingDirectory))
            {
                runner.AddArgument("-C");
                runner.AddQuotedArgument(workingDirectory !);
            }

            AddArguments(runner, gitArguments);
        }
Exemple #3
0
 void SetCommandArguments(ProcessRunner runner, string command, List <string>?commandArguments)
 {
     runner.AddArgument(command);
     if (commandArguments == null || commandArguments.Count == 0)
     {
         return;
     }
     AddArguments(runner, commandArguments);
 }
Exemple #4
0
        public async Task <Dictionary <string, BuildInfo> > GetBuildInfo(string logBasePath)
        {
            var    ret        = new Dictionary <string, BuildInfo> (StringComparer.Ordinal);
            string?binlogPath = GetBinLog(logBasePath);

            if (binlogPath == null)
            {
                return(ret);
            }

            bool echoOutputValue = EchoStandardOutput;

            EchoStandardOutput = false;

            try {
                ProcessRunner runner = CreateMSBuildRunner(forBinlog: true);
                runner.AddArgument("/v:diag");
                runner.AddQuotedArgument(binlogPath);

                using (var outputSink = (OutputSink)SetupOutputSink(runner)) {
                    outputSink.SuppressOutput = true;
                    outputSink.LineCallback   = (string l) => {
                        string line = l.Trim();
                        if (!line.StartsWith(BuildInfoMarker, StringComparison.Ordinal))
                        {
                            return;
                        }

                        BuildInfo?bi = ExtractBuildInfo(line);
                        if (bi == null)
                        {
                            return;
                        }

                        if (ret.ContainsKey(bi.TargetFramework))
                        {
                            throw new InvalidOperationException($"Duplicated target framework '{bi.TargetFramework}' info");
                        }

                        ret.Add(bi.TargetFramework, bi);
                    };

                    if (!await RunMSBuild(runner, setupOutputSink: false))
                    {
                        return(ret);
                    }
                }
            } finally {
                EchoStandardOutput = echoOutputValue;
            }

            return(ret);
        }
Exemple #5
0
        protected override ProcessRunner CreateMSBuildRunner(bool forBinlog)
        {
            ProcessRunner runner = CreateProcessRunner();

            if (forBinlog)
            {
                runner.AddArgument("msbuild");
            }

            runner.WorkingDirectory = WorkingDirectory;

            AddArguments(runner, StandardArguments);

            return(runner);
        }
Exemple #6
0
        public async Task <bool> Build(string projectPath, string logBasePath, string?configuration, List <string>?arguments = null)
        {
            ProcessRunner runner = CreateMSBuildRunner(forBinlog: false);
            string        cfg    = Utilities.FirstOf(configuration, Context.Configuration, Constants.DefaultConfiguration);

            runner
            .AddArgument("build")
            .AddArgument("--configuration")
            .AddQuotedArgument(cfg)
            .AddQuotedArgument($"/bl:{logBasePath}.binlog");

            AddArguments(runner, arguments);
            runner.AddQuotedArgument(projectPath);

            string message = GetLogMessage(runner);

            Log.InfoLine(message);

            return(await RunMSBuild(runner));
        }
Exemple #7
0
        public async Task <Dictionary <string, string> > GetPropertiesFromBinlog(string logBasePath, HashSet <string> neededProperties)
        {
            var    ret        = new Dictionary <string, string> (StringComparer.Ordinal);
            string?binlogPath = GetBinLog(logBasePath);

            if (binlogPath == null)
            {
                return(ret);
            }

            bool echoOutputValue = EchoStandardOutput;

            EchoStandardOutput = false;
            try {
                ProcessRunner runner = CreateMSBuildRunner(forBinlog: true);
                runner.AddArgument("/v:diag");
                runner.AddQuotedArgument(binlogPath);

                bool propertiesStarted = false;
                int  propertiesFound   = 0;
                using (var outputSink = (OutputSink)SetupOutputSink(runner)) {
                    outputSink.SuppressOutput = true;
                    outputSink.LineCallback   = (string l) => {
                        string line = l.Trim();
                        if (!propertiesStarted)
                        {
                            propertiesStarted = line.EndsWith("Initial Properties:");
                            return;
                        }
                        else if (propertiesFound == neededProperties.Count)
                        {
                            return;
                        }

                        int idx = line.IndexOf('=');
                        if (idx < 0)
                        {
                            return;
                        }

                        string propName = line.Substring(0, idx - 1);
                        if (!neededProperties.Contains(propName))
                        {
                            return;
                        }

                        ret [propName] = line.Substring(idx + 1).Trim();
                        propertiesFound++;
                    };

                    if (!await RunMSBuild(runner, setupOutputSink: false))
                    {
                        return(ret);
                    }
                }
            } finally {
                EchoStandardOutput = echoOutputValue;
            }

            return(ret);
        }