Set the environment variable to enable colorful output by default
See original GitHub issueDescription:
.NET previously disabled console colors if it detected that the output was redirected. Recently, a new environment variable has been added to override this: https://github.com/dotnet/runtime/pull/47935
Setting below environment variables will enable colorful output when running on GitHub Actions (not on Windows though):
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION
to1
ortrue
TERM
toxterm
Relevant discussion explaining the need for the second variable: https://github.com/dotnet/runtime/discussions/68302#discussioncomment-2605104
Justification:
Colorful output is much easier to visually parse and, since we can guarantee that we’re always running on GitHub Actions (which supports ansi color escape codes), it makes sense to make this setting enabled by default. As the worst case, this should be at least added as one of the action inputs, but I think enabling it by default is the way to go (not anymore, read comments below).
Are you willing to submit a PR?
Sure
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:9 (1 by maintainers)
Top GitHub Comments
This is actually the case with
FORCE_COLOR
in node with thesetup-node
action (ref: https://github.com/actions/setup-node/issues/317). When enabling that and using the cache option the post setup step fails because of the color codes in the log. The solution there is to disable that setting on thesetup-node
step, but it does catch you off guard if you don’t know about it.I understand your point, but here’s why I think it makes sense as an addition to
setup-dotnet
:DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION
andTERM
) are used to convincedotnet
that the output terminal/renderer supports color codes. This is always true in case with GitHub Actions.setup-dotnet
would guarantee that everyone gets it.That said, there may be some edge-cases such as if some step relies on the output of a
dotnet
command to have a specific format (for example regex) that this option may break. Because of this, I now realize it’s probably not a great idea to have it enabled by default in those cases (unless with a major version bump?).In any case, I leave the decision with you 😃 I’m personally okay setting this manually for my own projects.