How do I set the value in a command shell for dotnet core
Solution 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
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
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
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. Be aware that this only works pre-installation! To opt out after you've already installed the SDK, you have to set the environment variable, and then re-run the installer with this value set:
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
Hamza Ahmed
I'm an orchestrator albeit for software. I've been playing on the keyboard for close to a decade; mostly with the DotNet Ecosystem. I believe in standing firmly on the shoulders of giants. They act as a good base ;-) For purists I have a Master Degree in Electrical and Computer Engineering. Feel free to contact me for DotNet Projects.
Updated on July 09, 2022Comments
-
Hamza Ahmed almost 2 years
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.
How do I set this variable?
Thanks for your time.
-
Hamza Ahmed over 7 yearsset DOTNET_CLI_TELEMETRY_OPTOUT=1 -> WORKS However setx DOTNET_CLI_TELEMETRY_OPTOUT=1 -> DOES NOT
-
Marquizzo about 5 yearsIs there a way to
get
the value after usingsetx
to confirm it was stored? -
ZenoArrow about 4 yearsYou can check the values using "set" (without quotes). Just enter set without trying to define an environment variable and you'll get the list of environment variables currently defined (including those defined using setx).
-
ecif over 2 years@HamzaAhmedZia lose the "=" for setx