private static async Task ExecuteCommandAsync(RunCommandArguments arguments, IHost host)
        {
            var executor = host.Services.GetRequiredService <IProcessExecutor>();

            await executor.ExecuteProcess(new ProcessStartInfo
            {
                FileName       = "dotnet",
                Arguments      = GetArguments(arguments),
                CreateNoWindow = true
            }).ConfigureAwait(false);
        }
        private static string GetArguments(RunCommandArguments arguments)
        {
            _ = arguments ?? throw new ArgumentNullException(nameof(arguments));

            _ = arguments.PathToProgram ?? throw new ArgumentException($"{nameof(RunCommandArguments.PathToProgram)} should not be null.", nameof(arguments));

            return(arguments.ProgramArguments switch
            {
                null => arguments.PathToProgram.FullName,
                _ => $"{arguments.PathToProgram.FullName} {arguments.ProgramArguments}"
            });
Exemple #3
0
        private static async Task ExecuteCommandAsync(RunCommandArguments arguments, IHost host)
        {
            _ = arguments ?? throw new ArgumentNullException(nameof(arguments));

            _ = arguments.PathToProgram ?? throw new ArgumentException($"{nameof(RunCommandArguments.PathToProgram)} should not be null.", nameof(arguments));

            var executor = host.Services.GetRequiredService <IProcessExecutor>();

            await executor.ExecuteProcess(new ProcessStartInfo
            {
                FileName       = arguments.PathToProgram.FullName,
                Arguments      = arguments.ProgramArguments,
                CreateNoWindow = true
            }).ConfigureAwait(false);
        }