question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dotnet run does not preserve colors in child processes

See original GitHub issue

@mattwarren in BenchmarkDotNet brought this to my attention

Steps to reproduce

dotnet new

make Program.cs

using System;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("Hello World!");
        }
    }
}

dotnet restore dotnet run

Expected behavior

Outputs gray text

Actual behavior

save

Environment data

dotnet --version output:

C:\Users\brthor\code\repro\run-color>dotnet --version
.NET Command Line Tools (1.0.0-beta-001828)

Product Information:
 Version:     1.0.0-beta-001828
 Commit Sha:  N/A

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 Runtime Id:  win10-x64

I’d expect this to be present anywhere because we don’t do anything special to handle Console.SetColor or Console.ForegroundColor calls in child processes.

cc @anurse any ideas on how we could handle this?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:6
  • Comments:42 (35 by maintainers)

github_iconTop GitHub Comments

2reactions
stajscommented, Sep 21, 2016

Has this fix been released? I’m still seeing uncolored output when using dotnet watch.

C:\>dotnet --info
.NET Command Line Tools (1.0.0-preview2-003131)

Product Information:
 Version:            1.0.0-preview2-003131
 Commit SHA-1 hash:  635cf40e58

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 RID:         win10-x64
2reactions
shanselmancommented, Jun 20, 2016

This is a problem, it seems, with all things that wrap dotnet run, like dotnet test and dotnet watch.

I am seeing this even today with 1.0.0-preview2-003119. That’s pretty new. We need to fix this soon IMHO, it’s super annoying. @Eilon image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotnet run does not preserve colors in child processes #5432
To be clear, run is fine. Stuff that is outside/wrapping run doesn't. See the screenshot. Test and Watch (the ones folks will use...
Read more >
preserve color when executing child_process.spawn
I'm trying to execute a windows command through cmd.exe in node.js using child_process.spawn. It executes correctly, but only displays in ...
Read more >
Cannot debug net6.0-macos Apps - Developer Community
This is a regression. I can no longer debug net6.0-macos apps. It also fails for net6.0-maccatalyst apps. When I hit debug, the following ......
Read more >
Call JavaScript functions from .NET methods in ASP. ...
This article explains how to invoke JavaScript (JS) functions from .NET. For information on how to call .NET methods from JS, see Call...
Read more >
dotnet watch command - .NET CLI
The dotnet watch command is a file watcher that runs a dotnet command when changes in source code are detected.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found