Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

COLOR does and does not color with dotnet.exe

Aug
2,799
144
dotnet.exe causes issues with the font color in TCC.

This is nothing new,
it has been going on for a few years,
not a big issue,
just an irritating issue.

Yes, "talk to Microsoft".

An excerpt from test.btm;

Code:
@SETLOCAL
@ECHO OFF
if isdir r:\temp set temp=r:\temp
rem "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\msbuild.exe" "E:\Documents\jlcUtils\jlcUtils.csproj" /t:Build /p:Configuration=Release /p:PlatformTarget=x64 /m
dotnet build jlcUtils.csproj -c Release -p:PlatformTarget=x64 --no-restore -v:diag

echo %_fg / %_bg
color bright green on black
echo %_fg / %_bg

iff %? ne 0 then
  echo Error when using dotnet to complile project: %?
  quit
endiff

echo.
echo Loading plugin

1786029708582.webp


Note that dotnet.exe causes my font color to go from Bright Green on Black to Black on Black,
even though the color output appears as White on Black.

Even after using the color command to change the color to Bright Green on black,
tcc still says the color is Black on Black,
even though the color is now Bright Green on Black.

Running this after test.btm has been completed;
Code:
E:\...\jlcUtils>echo %_fg / %_bg
Bri Gre / Bla

For reference;
Code:
E:\...\jlcUtils>ffind /lvt"color" test.btm

---- E:\Documents\jlcUtils\test.btm
[9] color bright green on black

  1 line in      1 file
dotnet.exe also causes the same problem when running in PowerShell 5.1;

Code:
PS E:\documents\jlcutils> $host.UI.RawUI.ForegroundColor
Green
PS E:\documents\jlcutils> $host.UI.RawUI.BackgroundColor
Black
PS E:\documents\jlcutils> dotnet build jlcUtils.csproj -c Release -p:PlatformTarget=x64 --no-restore -v:diag
  jlcUtils net48 succeeded (0.6s) → bin\Release\jlcUtils.dll

Build succeeded in 1.4s
PS E:\documents\jlcutils> $host.UI.RawUI.ForegroundColor
Gray
PS E:\documents\jlcutils> $host.UI.RawUI.BackgroundColor
Black
PS E:\documents\jlcutils>

...but PowerShell 5.1 (running under Windows Terminal Version: 1.24.11911.0) handles the color reporting correctly,
compared to TCC

1786031546272.webp
MSBuild.exe does not cause these problems with the color.

Complete TCC info is cited below.

Joe

Code:
E:\...\jlcUtils>dotnet --version
10.0.302

E:\...\jlcUtils>tccinfo.btm
   _admin: 1     _admin is an internal variables
_elevated: 1     _elevated is an internal variable
  _parent: C:\WINDOWS\Explorer.EXE
  _conpty: 0     _conpty is an internal variable
 _cmdspec: C:\Program Files\JPSoft\TCMD36\TCC.EXE
 _contype: Console

TCC  36.52.81 x64   Windows 10 [Version 10.0.19045.7548]
Active code page: 437
Font: Consolas  17 x 37
FaceName: Consolas, FontFamily: 54, FontWeight: 400, FontSize: 17x37
BuildNumber  Caption                   CSDVersion  OSArchitecture  Version
19045        Microsoft Windows 10 Pro              64-bit          10.0.19045

22H2
Manufacturer  Model
Dell Inc.     Precision T5610

* \\.\DISPLAY1, NVIDIA Quadro K4000
     Monitor: MONITOR\GSM56FF\{4d36e96e-e325-11ce-bfc1-08002be10318}\0002
     Refresh rate: 59 Hz
     Color depth: 32
     Screen resolution: 1920 x 1080
     Scaling: 100%  (DPI 96 x, 96 y)
  \\.\DISPLAY2, NVIDIA Quadro K4000
  \\.\DISPLAY3, NVIDIA Quadro K4000
  \\.\DISPLAY4, NVIDIA Quadro K4000
 
Interesting.

If I redirect the output of dotnet.exe;

Code:
@SETLOCAL
@ECHO OFF
if isdir r:\temp set temp=r:\temp
rem "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\msbuild.exe" "E:\Documents\jlcUtils\jlcUtils.csproj" /t:Build /p:Configuration=Release /p:PlatformTarget=x64 /m
rem dotnet build jlcUtils.csproj -c Release -p:PlatformTarget=x64 --no-restore
dotnet build jlcUtils.csproj -c Release -p:PlatformTarget=x64 --no-restore -v:diag > r:\result.txt

echo %_fg / %_bg
color bright green on black
echo %_fg / %_bg

iff %? ne 0 then
  echo Error when using dotnet to complile project: %?
  quit 
endiff

echo.
echo Loading plugin

1786050263804.webp


So, with redirection,
Instead of

Bla / Bla

I get

Whi / Bla

...even though it should be

Bri Gre / Bla

Joe
 
Because of some buggy MS apps (and APIs), if you set text to black on black, TCC will switch to white on black. Yes, I know that somebody might want to set black on black to hide text -- but if you really want to hide your text, then don't print it.

The "default" TCC colors are actually two sets of colors. One is the default console colors, and the other is the default ANSI colors. If you set the ANSI colors by writing an ANSI sequence to STDOUT, it does not change the default console colors (though they are not used unless you do an ANSI reset), and TCC does not know that the color changed.

dotnet.exe is changing the console color palette (as does powershell). Since changing the palette could include wacky things like changing green to red and vice versa. or defining 15 shades of green instead of the normal 8 + 8 bright colors, there's no way that TCC can know if the name of a color is still valid or meaningful
 
Back
Top