示例#1
0
        async Task CustomCommandAsync(IAsyncProject project, Gamelet gamelet, DataRecorder record,
                                      string command)
        {
            var startInfo = new ProcessStartInfo
            {
                FileName         = Path.Combine(Environment.SystemDirectory, YetiConstants.Command),
                Arguments        = $"/C \"{command}\"",
                WorkingDirectory = await project.GetAbsoluteRootPathAsync(),
            };

            startInfo.EnvironmentVariables[GgpInstanceIdName] = gamelet.Id;
            Stopwatch stopwatch = Stopwatch.StartNew();

            using (IProcess process = _managedProcessFactory.CreateVisible(startInfo, int.MaxValue))
            {
                try
                {
                    await process.RunToExitWithSuccessAsync();

                    record.CustomDeploy(stopwatch.ElapsedMilliseconds, DataRecorder.NoError);
                }
                catch (ProcessException e)
                {
                    Trace.WriteLine("Error running custom deploy command: " + e);
                    record.CustomDeploy(stopwatch.ElapsedMilliseconds, e);
                    throw new DeployException(
                              ErrorStrings.ErrorRunningCustomDeployCommand(e.Message), e);
                }
            }
        }