- Added
PipeSource.FromFile(...)
andPipeTarget.ToFile(...)
as convenience shorthands for creating pipes that work withFileStream
instances. - Added overloads for
ArgumentsBuilder.Add(...)
that takeIFormatProvider
instead ofCultureInfo
. In a future major version, the overloads that takeCultureInfo
will be removed. - Improved performance of
PipeSource.Null
andPipeTarget.Null
. - Signed assembly. (Thanks @lazyboy1)
Known incompatibility issue: Using CliWrap together with ConfigureAwait.Fody, in code compiled with .NET 5.0 SDK or higher, results in a NullReferenceException
at run time. The recommended workaround is to call ConfigureAwait(...)
on CliWrap.CommandTask<T>
manually or to disable ConfigureAwait.Fody
altogether.
- Fixed an issue where
PipeTarget.ToDelegate(...)
, as well as execution models that depend on it (i.e. observable and async streams), didn't treat standalone\r
character as a valid linebreak. (Thanks @koryphaee)
- Fixed an issue where
Command.ExecuteAsync(...)
sometimes threwInvalidOperationException
indicating that the process has already exited. This problem only happened on Linux and macOS when the process exited too quickly. - Improved performance and memory usage in async event stream execution model.
- Fixed an issue where
Command.ExecuteAsync(...)
sometimes returned before the process actually exited, in case cancellation was requested. Now, this method only returns when the process has fully terminated or if the termination has failed for whatever reason. - Fixed an issue where specifying password without also specifying domain resulted in the password being incorrectly ignored.
- Improved performance and memory usage in all execution models. (Thanks @Maarten Balliauw and @Miha Zupan)
- Added optimization for
PipeTarget.Merge(...)
that flattens inner targets in case they also represent merged targets. - Added
CommandTask.ConfigureAwait(...)
as a shorthand forCommandTask.Task.ConfigureAwait(...)
.
- Added support for specifying user credentials when you want to run a command as a different user. This can be done by calling
cmd.WithCredentials(...)
. Domain and password options are only supported on Windows, while username can be set on any operating system. (Thanks @Michi)
- Fixed an issue where
PipeTarget.Merge(...)
worked incorrectly when processing large stdout written in a single operation (more than 81920 bytes at a time). (Thanks @Tom Pažourek) - Replaced
[DebuggerDisplay]
attribute with an implementation ofToString()
on types deriving fromCommandEvent
. CallingcommandEvent.ToString()
now yields an informative string that can be useful in debugging. This change shouldn't have any unwanted side-effects.
- Added an option to disable automatic argument escaping to
cmd.WithArguments(string[])
as well asbuilder.Add(...)
. You can use it to escape the arguments yourself if the application requires it. - Added an option to enable or disable auto-flushing for
PipeTarget.ToStream(...)
andPipeSource.FromStream(...)
. If enabled, data will be copied as soon as it's available instead of waiting for the buffer to fill up. This is enabled by default, which is different from the previous behavior, although this change is not breaking for most scenarios. - Fixed an issue where command execution threw an exception if the wrapped application didn't read stdin completely. The exception is now caught and ignored as it's not really an exceptional situation if the stdin contains excess data which is discarded by the wrapped application.
- Fixed an issue where command execution waited for piped stdin to resolve next bytes, even if the wrapped application didn't try to read them. This avoids unnecessary delay (which can be infinite if the stream never resolves) when the wrapped application doesn't need the rest of the stdin to complete execution.
- Fixed an issue where
PipeTarget.Merge(...)
worked incorrectly when used withPipeTarget.ToDelegate(...)
, causing the latter to yield lines even where there were no line breaks.
- Added error handling for when the internal call to
Process.Start()
returnsfalse
. This will now throw a more descriptive exception than it did previously.
- Fixed an issue where piping stdin to an executable that also writes stdout caused a deadlock when the stdout was beyond a certain size.
- Slightly improved performance by using
TaskCreationOptions.RunContinuationsAsynchronously
where appropriate. (Thanks @Georg Jung) - Added DebuggerDisplay attribute to derivatives of
CommandEvent
to aid in debugging. (Thanks @Zoltán Lehóczky)
- Complete rework of the library.
- Added extensive support for piping.
- Multitude of improvements and breaking changes.
Refer to the migration guide to see how you can update your old code to work with CliWrap v3.0.
Check out the new readme to see the whole list of new features.
- Added callbacks that trigger when stdout/stderr streams are closed. (Thanks @Daniel15)
- Added an overload for
SetCancellationToken
that acceptskillEntireProcessTree
. Passingtrue
to this option will make CliWrap attempt to kill the entire process tree when cancellation is requested, as opposed to only the parent process. Note, this option is only available on .NET Framework 4.5+ and .NET Core 3.0+. (Thanks @M-Patrone) - Removed ReSharper annotations.
- Added
ProcessId
property toCli
. You can use it to get the ID of the underlying process as soon as it's started.
- Fixed an issue where
Execute
andExecuteAsync
didn't return immediately after the execution was canceled. - Fixed an issue where setting the same environment variable twice resulted in an error.
- Improved exception message in
ExitCodeValidationException
andStandardErrorValidationException
.
- Added an overload for
SetArguments
that takes a list. You can pass multiple arguments and they will be automatically encoded to preserve whitespace and other special characters. - Fixed some typos in documentation.
- Fixed an issue where
ExecuteAndForget
was throwing an exception if the underlying process outlived the execution of the method.
ExitCodeValidationException
andStandardErrorValidationException
now display both exit code and standard error inside the message. Useful when a process reported a non-zero exit code but the actual error message is in stderr.- Removed
netcoreapp1.0
target.
- Added
Cli.Wrap
static method to replacenew Cli()
for a more fluent interface. This also makes it so you're dealing withICli
instead ofCli
throughout the entire method chain. - Standard error validation is now disabled by default. This change was made because quite a few CLIs (e.g. git, ffmpeg) write progress to stderr.
- Changed
Execute
andExecuteAsync
to complete only after the process exits, regardless of cancellation. This fixes a problem where the underlying process could live for some brief moments after those methods returned, in case of cancellation. - If
Execute
orExecuteAsync
is canceled, the underlying process will now be killed without waiting for standard input to write completely. - Reworked underlying process handling to improve performance and maintainability. The
Execute
andExecuteAsync
methods are now virtually the same in terms of code, unlike before, where they were considerably different.
- Added
ExecutionResult
toExitCodeValidationException
andStandardErrorValidationException
. This way additional information can be inspected during debugging. ExitCodeValidationException
andStandardErrorValidationException
are now derived fromExecutionResultValidationException
.- Improved cancellation handling in synchronous workflow.
- Cancellation token is now used when writing stdin in asynchronous workflow.
- Methods that used to return an instance of
Cli
now returnICli
where applicable.
- Re-designed the API so that it follows the builder pattern. Execution parameters are now supplied using chainable methods on the
Cli
instead of viaExecutionInput
. Things likeBufferHandler
andCancellationToken
are now also configured in the same manner. Refer to the readme to see updated usage examples. - It is now also possible to pipe a raw stream to standard input, instead of just a text string.
- Removed
ExecutionInput
,CliSettings
,BufferHandler
,EncodingSettings
. - Renamed
ExecutionOutput
toExecutionResult
. - Removed
ExecutionResult.HasError
andExecutionResult.ThrowIfError()
. - Added an option to automatically throw an exception when the underlying process reports a non-zero exit code. Is enabled by default.
- Added an option to automatically throw an exception when the underlying process writes anything to standard error. Is enabled by default.
- Fixed exception messages not appearing in Visual Studio's exception popup.
StandardErrorException
now shows the value ofStandardError
inMessage
.
- Added
ICli
to aid in testing.
- Made input model classes more accessible by removing immutability.
Cli
now throws exception if used after getting disposed.
- Fixed another process leak when canceling synchronous
Execute
.
- Refactored additional
Cli
constructor parameters into a separate class calledCliSettings
. This is breaking if you used to supply more than 1 parameter to the constructor. Execute
andExecuteAsync
no longer depend on process getting successfully killed. An attempt to kill it is made but if it's not successful, no exception is thrown.- All
CancellationToken
callbacks are now exception-safe. - Fixed an issue where
CancellationToken
would throw an out of scope exception when the process could not be killed. - Fixed a race condition when an execution task is completed and canceled at the same time.
- Added
EncodingSettings
to customize stream encoding. - Added some ReSharper annotations to improve warnings and suggestions.
- Execution start and exit times are now calculated separately, without accessing
Process
instance. - Execution start and exit times are now
DateTimeOffset
instead ofDateTime
. - Fixed an issue that prevented CliWrap from properly working on Linux.