cake-build / cake-vso

Cake integration for Azure DevOps.
https://marketplace.visualstudio.com/items/cake-build.cake
18 stars 18 forks source link

Logging in Release adds additional characters #70

Closed Kontekst closed 2 years ago

Kontekst commented 3 years ago

Cake logging commands using interpolation arguments are adding additional characters in AzDevOps output during release. Similar characters are sometimes added for default information printed on start/end of task (like "Executing task..", "Finished executing task...").

image

I ran below Cake script in Cake task with version 2*(2.1.0 in logs) during AzDevOps Release on my custom agent , problem occurs for 3 verbosity levels(Normal, Verbosity, Diagnostic).

`Task("Default") .Does(() => { var testInfo = "Hello world";

Information("Information test");

Debug("Debug test");

Error("Error test");

Verbose("Verbose test");

Warning("Warning test");

Information("TestInfo 1 = {0}", testInfo);

}); RunTarget("Default");`

Kontekst commented 3 years ago

I have created example public repo and pipeline with Minimal, Reproducible Example

test.cake https://dev.azure.com/tomaszkontek/FeaturesTesting/_git/CakeVerbosityOutput?path=%2Ftest.cake

release with corrupted output https://dev.azure.com/tomaszkontek/FeaturesTesting/_releaseProgress?_a=release-pipeline-progress&releaseId=2

nils-a commented 2 years ago

This is due to the fact that Azure DevOps supports colorization in the output using ANSI escape codes. Cake (or rather the underlying spectre.console) detects this and uses these codes to colorize the output.

However, in the downloaded logs which are (naturally) text-only, these escape codes appear as you highlighted above. I would suggest having a look at Cake.Buildsystems.Module, which supports changing the output according to the underlying CI system. Cake.Buildsystems.Module currently has a similar problem (see https://github.com/cake-contrib/Cake.BuildSystems.Module/issues/108) but it seems that might be fixed soon.

Kontekst commented 2 years ago

I have fixed this behavior by setting 'NO_COLOR' environment variable on agent host. https://cakebuild.net/docs/running-builds/configuration/default-configuration-values#disable-colors-in-output-text

I think this issue can be closed.