public async Task DoWork(MessageDefinitions message)
        {
            // Long running process;
            await Task.Delay(4000);
            var tobeCompiledPath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, @"..\..\ToBeCompiled");
            var projectPath = $"{tobeCompiledPath}\\{message.Recipient.AssemblyName}";

            Process process = new Process()
            {
                StartInfo = new ProcessStartInfo("cmd")
                {
                    WorkingDirectory = projectPath,
                    RedirectStandardInput = true,
                    RedirectStandardOutput = true,
                    UseShellExecute = false,
                    CreateNoWindow = true
                }
            };

            process.Start();
            // only if the command preceding the symbol is successful
            process.StandardInput.WriteLine("dotnet build");
            process.StandardInput.Flush();

            string output = process.StandardOutput.ReadToEnd();

            process.WaitForExit();
            process.Dispose();

            Console.WriteLine(output);

            var context = new OperationResultContext
            {
                ClientId = ClientId,
                Command = Commands.Build,
                CompletedDate = DateTime.Now,
                State = OperationResultState.Success,
                ResultInfo = output
            };
            await PostStatus(context);
        }
示例#2
0
 public byte[] CreateJsonMessage(MessageDefinitions messageDefinitions)
 {
     return(messageDefinitions.CreateJson().ToUtf8Bytes());
 }