Search code examples
dotnet-cli

How can I suppress .NET CLI's welcome message on first run?


I am using .NET CLI in an Azure DevOps pipeline, and I am using PowerShell to parse its output. The first command I run is dotnet nuget locals global-packages --list.

The output when you run this the first time is this:


Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.101

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
global-packages: C:\Users\VssAdministrator\.nuget\packages\

As you can see, there is a whole story about telemetry, certificates, and some links, followed by the simple output that I need to parse. Running it again just outputs that last line:

global-packages: C:\Users\VssAdministrator\.nuget\packages\

I need to suppress this output, because it makes automation more difficult.


Solution

  • According to this post, .NET Core 3.1 added an environment variable called DOTNET_NOLOGO, which, when set (to 1? to anything?) will suppress the welcome message.

    This, much more recent post confirms it's still relevant.

    Can you add this env variable to your CI pipeline environment?