示例#1
0
        private async Task <TaskResult> PreProcessSession(IServerSession session)
        {
            await session.InitializeAsync();

            try {
                session.OnPreBuildEvent();
            }
            catch (OperationCanceledException) {
                throw;
            }
            catch (Exception error) {
                throw new ApplicationException("Pre-Build event Failed!", error);
            }

            try {
                session.Output.WriteLine("Preparing working directory...", ConsoleColor.DarkCyan);

                await session.PrepareWorkDirectoryAsync();
            }
            catch (OperationCanceledException) {
                throw;
            }
            catch (Exception error) {
                var _e = error;
                if (error is AggregateException _ae)
                {
                    _e = _ae.Flatten();
                }

                throw new ApplicationException("Pre-Build event Failed!", _e);
            }

            try {
                session.Output.WriteLine("Running script...", ConsoleColor.DarkCyan);

                await session.RunAsync();

                return(TaskResult.Ok());
            }
            catch (OperationCanceledException) {
                throw;
            }
            catch (Exception error) {
                throw new ApplicationException("Script Failed!", error);
            }
        }