Skip to content

Enable console color output by default #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ Some environment variables may be necessary for your particular case or to impro
- DOTNET_CLI_TELEMETRY_OPTOUT - opt-out of telemetry being sent to Microsoft (default: false)
- DOTNET_MULTILEVEL_LOOKUP - configures whether the global install location is used as a fall-back (default: true)

**Note** Sets `DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION` and `TERM` to force color output by default (https://github.com/actions/setup-dotnet/issues/288).
- DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION = true
- TERM = xterm

Example usage:
```yaml
build:
Expand Down
5 changes: 5 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ class DotnetCoreInstaller {
}
console.log(process.env['PATH']);
}
static enableConsoleColorOutput() {
core.exportVariable('DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION', 'true');
core.exportVariable('TERM', 'xterm');
}
// versionInfo - versionInfo of the SDK/Runtime
resolveVersion(versionInfo) {
return __awaiter(this, void 0, void 0, function* () {
Expand Down Expand Up @@ -486,6 +490,7 @@ function run() {
yield dotnetInstaller.installDotnet();
}
installer.DotnetCoreInstaller.addToPath();
installer.DotnetCoreInstaller.enableConsoleColorOutput();
}
const sourceUrl = core.getInput('source-url');
const configFile = core.getInput('config-file');
Expand Down
8 changes: 8 additions & 0 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ export class DotnetCoreInstaller {
console.log(process.env['PATH']);
}

static enableConsoleColorOutput() {
core.exportVariable(
'DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION',
'true'
);
core.exportVariable('TERM', 'xterm');
}

// versionInfo - versionInfo of the SDK/Runtime
async resolveVersion(versionInfo: DotNetVersionInfo): Promise<string> {
if (versionInfo.isExactVersion()) {
Expand Down
1 change: 1 addition & 0 deletions src/setup-dotnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export async function run() {
await dotnetInstaller.installDotnet();
}
installer.DotnetCoreInstaller.addToPath();
installer.DotnetCoreInstaller.enableConsoleColorOutput();
}

const sourceUrl: string = core.getInput('source-url');
Expand Down