【问题标题】:How can I suppress .NET CLI's welcome message on first run?如何在首次运行时抑制 .NET CLI 的欢迎消息?
【发布时间】:2022-01-26 07:31:48
【问题描述】:

我在 Azure DevOps 管道中使用 .NET CLI,并使用 PowerShell 解析其输出。我运行的第一个命令是dotnet nuget locals global-packages --list

第一次运行时的输出是这样的:


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\

如您所见,有一个关于遥测、证书和一些链接的完整故事,然后是我需要解析的简单输出。再次运行它只会输出最后一行:

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

我需要抑制这个输出,因为它使自动化变得更加困难。

【问题讨论】:

    标签: dotnet-cli


    【解决方案1】:

    根据this post,.NET Core 3.1 添加了一个名为DOTNET_NOLOGO 的环境变量,当设置(设置为 1?对任何东西?)时,将抑制欢迎消息。

    这个,更多 recent post 确认它仍然相关。

    您能否将此 env 变量添加到您的 CI 管道环境中?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-09
      • 1970-01-01
      • 2013-08-04
      • 1970-01-01
      • 2021-12-24
      • 2020-01-01
      • 2021-01-25
      • 1970-01-01
      相关资源
      最近更新 更多