'How do I set the value in a command shell for dotnet core

Running dotnet core command dotnet run in a command line I found this

You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.

DOTNET_CLI_TELEMETRY_OPTOUT

How do I set this variable?

Thanks for your time.



Solution 1:[1]

On Windows use

set DOTNET_CLI_TELEMETRY_OPTOUT=1

to avoid that telemetry data is sent by dotnet.exe in the current command line session.

Or use

setx DOTNET_CLI_TELEMETRY_OPTOUT 1

do disable this feature permanently.

Solution 2:[2]

To set environment variable only for current cmd session write set DOTNET_CLI_TELEMETRY_OPTOUT=1 or set DOTNET_CLI_TELEMETRY_OPTOUT=true (according to .NET Core Tools Telemetry)

To set environment variable permanently use setx instead of set.

Edit: For setx it has to be setx DOTNET_CLI_TELEMETRY_OPTOUT 1, and changes will only take effect when a new command window is opened - they do not affect the current CMD.

Developer Command Prompt is started with this .bat file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat so you can edit it and add permanent changes.

Solution 3:[3]

In MacOS, use

echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" | sudo tee -a /etc/environment

to add the variable setting to your environment.

http://gigi.nullneuron.net/gigilabs/net-core-tools-telemetry/

Solution 4:[4]

For Bash on Unix-like operating systems (you can find out if you're using Bash by typing echo $SHELL in your terminal), you can do the following:

For temporary opt-out for your user (reverts when you close your terminal session):

Set the variable

DOTNET_CLI_TELEMETRY_OPTOUT=1

Test if variable was set correctly (should see a 1 output)

echo $DOTNET_CLI_TELEMETRY_OPTOUT

For permanent opt-out for your user

Open .bashrc in your text editor of choice (for Fedora the default is GNU Nano)

nano $HOME/.bashrc

Scroll to bottom of file. Add the following line

export DOTNET_CLI_TELEMETRY_OPTOUT=1

Save and exit (in GNU Nano, you can hit ctrl+x, and it will ask you to save). Then restart your terminal session.

 exec bash

Test if variable was set correctly (should see a 1 output):

echo $DOTNET_CLI_TELEMETRY_OPTOUT

Solution 5:[5]

For fish shell user,

set -Ux DOTNET_CLI_TELEMETRY_OPTOUT 1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrey K.
Solution 2
Solution 3 Cosmo Hidalgo
Solution 4
Solution 5 foxiris