The main purpose of this to dump the process command and arguments in string format for later execution or use it (for example use to run inside Docker). I would like to run the system related tests in a build process based on cake generated test commands in separated environments (like Docker swarm service in compose/swarm stack).
Cake dotnet Test command:
DotNetCoreTest(SolutionFile, new DotNetCoreTestSettings
{
Configuration = configuration,
Verbosity = DotNetCoreVerbosity.Normal,
NoBuild = true,
NoRestore = true
});
and the expected (or similar) output:
FilePath: /Users/felegy/homebrew/bin/dotnet
ProcessSettings.Arguments: test --configuration Release --verbosity normal --no-restore --no-build
Clone the gist repo and run the commands in a gists folder.
# Install Cake
dotnet tool install -g Cake.Tool
# Execute build process // in standard mode
dotnet cake
# And run again to dump command
dotnet cake --fake-run=true
- Important to refer the Context in a task declaration:
Task("Default")
.Does(ctx =>
- Use the command constructor can to change context elements:
var tester = new DotNetCoreTester(
ctx.FileSystem,
ctx.Environment,
processRunner, // change the ctx.ProcessRunner => FakeProcessRunner
ctx.Tools
);
- Command execution:
tester.Test("", settings);
- Dump the command and arguments:
Information($"FilePath:{fakeRunner.FilePath}");
Information($"ProcessSettings.Arguments:{fakeRunner.ProcessSettings.Arguments.Render()}");
In any kind of situation when logging ability is enough, this is a lighter and better solution (thanks a lot @petriashev):
In any kind of situation when logging ability is enough, this is a lighter and better solution (thanks a lot @petriashev):
https://stackoverflow.com/questions/50826394/how-to-print-tool-command-line-in-cake/50826495?r=SearchResults#50826495