dotnet 命令dotnet command

本文 適用于: ✔️ .net CORE 2.1 SDK 和更新版本This article applies to: ✔️ .NET Core 2.1 SDK and later versions

名稱Name

dotnet -.NET CLI 的一般驅動程式。dotnet - The generic driver for the .NET CLI.

概要Synopsis

若要取得可用命令和環境的相關資訊:To get information about the available commands and the environment:

dotnet [--version] [--info] [--list-runtimes] [--list-sdks]

dotnet -h|--help

若要執行命令 (需要 SDK 安裝) :To run a command (requires SDK installation):

dotnet <COMMAND> [-d|--diagnostics] [-h|--help] [--verbosity <LEVEL>]
    [command-options] [arguments]

若要執行應用程式:To run an application:

dotnet [--additionalprobingpath <PATH>] [--additional-deps <PATH>]
    [--fx-version <VERSION>]  [--roll-forward <SETTING>]
    <PATH_TO_APPLICATION> [arguments]

dotnet exec [--additionalprobingpath] [--additional-deps <PATH>]
    [--fx-version <VERSION>]  [--roll-forward <SETTING>]
    <PATH_TO_APPLICATION> [arguments]

--roll-forward 自 .NET Core 3.x 起提供。--roll-forward is available since .NET Core 3.x. 用於 --roll-forward-on-no-candidate-fx .Net Core 2.x。Use --roll-forward-on-no-candidate-fx for .NET Core 2.x.

描述Description

dotnet 命令有兩個功能:The dotnet command has two functions:

  • 它提供使用 .NET 專案的命令。It provides commands for working with .NET projects.

    例如, dotnet build 建立專案。For example, dotnet build builds a project. 每個命令都會定義自己的選項和引數。Each command defines its own options and arguments. 所有命令都支援 --help 列印出有關如何使用命令的簡短檔的選項。All commands support the --help option for printing out brief documentation about how to use the command.

  • 它會執行 .NET 應用程式。It runs .NET applications.

    您可以指定應用程式檔的路徑 .dll 來執行應用程式。You specify the path to an application .dll file to run the application. 若要執行應用程式,您可以尋找並執行進入點,在主控台應用程式的案例中,這是 Main 方法。To run the application means to find and execute the entry point, which in the case of console apps is the Main method. 例如,會 dotnet myapp.dll 執行 myapp 應用程式。For example, dotnet myapp.dll runs the myapp application. 若要瞭解部署選項,請參閱 .net 應用程式部署See .NET application deployment to learn about deployment options.

選項Options

您可以使用不同的選項來執行 dotnet 命令,以及執行應用程式。Different options are available for dotnet by itself, for running a command, and for running an application.

Dotnet 本身的選項Options for dotnet by itself

以下是本身的選項 dotnetThe following options are for dotnet by itself. 例如,dotnet --infoFor example, dotnet --info. 他們會列印環境的相關資訊。They print out information about the environment.

  • --info

    列印 .NET 安裝和電腦環境的詳細資訊,例如目前的作業系統,以及 .NET 版本的認可 SHA。Prints out detailed information about a .NET installation and the machine environment, such as the current operating system, and commit SHA of the .NET version.

  • --version

    列印出使用中的 .NET SDK 版本。Prints out the version of the .NET SDK in use.

  • --list-runtimes

    列印已安裝之 .NET 執行時間的清單。Prints out a list of the installed .NET runtimes. X86 版本的 SDK 只會列出 x86 執行時間,而 x64 版本的 SDK 只會列出 x64 執行時間。An x86 version of the SDK lists only x86 runtimes, and an x64 version of the SDK lists only x64 runtimes.

  • --list-sdks

    列印已安裝的 .NET Sdk 清單。Prints out a list of the installed .NET SDKs.

  • -h|--help

    列印出可用命令的清單。Prints out a list of available commands.

用來執行命令的 SDK 選項SDK options for running a command

以下是 dotnet 使用命令的選項。The following options are for dotnet with a command. 例如,dotnet build --helpFor example, dotnet build --help.

  • -d|--diagnostics

    啟用診斷輸出。Enables diagnostic output.

  • -v|--verbosity <LEVEL>

    設定命令的詳細資訊層級。Sets the verbosity level of the command. 允許的值為 q[uiet]m[inimal]n[ormal]d[etailed]diag[nostic]Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. 不支援每個命令。Not supported in every command. 請參閱特定的命令頁面,判斷此選項是否可用。See specific command page to determine if this option is available.

  • -h|--help

    印出指定命令的文件,例如dotnet build --helpPrints out documentation for a given command, such as dotnet build --help.

  • command options

    每個命令都會定義該命令特定的選項。Each command defines options specific to that command. 請參閱特定的命令頁面,以取得可用選項的清單。See specific command page for a list of available options.

執行時間選項Runtime options

當您執行應用程式時,可以使用下列選項 dotnetThe following options are available when dotnet runs an application. 例如,dotnet myapp.dll --roll-forward MajorFor example, dotnet myapp.dll --roll-forward Major.

  • --additionalprobingpath <PATH>

    包含探查原則和要探查之組件的路徑。Path containing probing policy and assemblies to probe.

  • --additional-deps <PATH>

    其他 .deps.json 檔案的路徑。Path to an additional .deps.json file. 檔案 deps.js 包含相依性、編譯相依性的清單,以及用來解決元件衝突的版本資訊。A deps.json file contains a list of dependencies, compilation dependencies, and version information used to address assembly conflicts. 如需詳細資訊,請參閱 GitHub 上的 Runtime Configuration Files (執行階段組態檔)。For more information, see Runtime Configuration Files on GitHub.

  • --depsfile <PATH_TO_DEPSFILE>

    檔案 deps.js 的路徑。Path to the deps.json file. 檔案 上的deps.js 是一個設定檔,其中包含執行應用程式所需相依性的相關資訊。A deps.json file is a configuration file that contains information about dependencies necessary to run the application. 這個檔案是由 .NET SDK 產生。This file is generated by the .NET SDK.

  • --runtimeconfig

    runtimeconfig.json 檔案的路徑。Path to a runtimeconfig.json file. 檔案 上的runtimeconfig.js 是包含執行時間設定的設定檔。A runtimeconfig.json file is a configuration file that contains run-time settings. 如需詳細資訊,請參閱 .net 執行時間設定For more information, see .NET run-time configuration settings.

  • --roll-forward <SETTING>****從 .NET Core SDK 3.0 開始提供。--roll-forward <SETTING> Available starting with .NET Core SDK 3.0.

    控制如何將向前復原套用至應用程式。Controls how roll forward is applied to the app. SETTING可以是下列其中一個值。The SETTING can be one of the following values. 如果未指定, Minor 則為預設值。If not specified, Minor is the default.

    • LatestPatch -向前復原到最高的修補程式版本。LatestPatch - Roll forward to the highest patch version. 這會停用次要版本向前復原。This disables minor version roll forward.
    • Minor -如果遺漏要求的次要版本,則向前復原到最低的次要版本。Minor - Roll forward to the lowest higher minor version, if requested minor version is missing. 如果要求的次要版本存在,則會使用 LatestPatch 原則。If the requested minor version is present, then the LatestPatch policy is used.
    • Major -如果缺少要求的主要版本,則向前復原到最低的最高主要版本,以及最低的次要版本。Major - Roll forward to lowest higher major version, and lowest minor version, if requested major version is missing. 如果要求的主要版本存在,則會使用 Minor 原則。If the requested major version is present, then the Minor policy is used.
    • LatestMinor -向前復原到最高的次要版本,即使有要求的次要版本存在也一樣。LatestMinor - Roll forward to highest minor version, even if requested minor version is present. 適用於裝載案例的元件。Intended for component hosting scenarios.
    • LatestMajor -向前復原到最高的主要和最高次要版本,即使有要求的主要存在。LatestMajor - Roll forward to highest major and highest minor version, even if requested major is present. 適用於裝載案例的元件。Intended for component hosting scenarios.
    • Disable -不要向前復原。Disable - Don't roll forward. 只會繫結至指定的版本。Only bind to specified version. 此原則不建議一般用途,因為它會停用向前復原到最新修補程式的功能。This policy isn't recommended for general use because it disables the ability to roll forward to the latest patches. 只有測試時才建議使用這個值。This value is only recommended for testing.

    除了之外 Disable ,所有設定都會使用最高可用的修補程式版本。With the exception of Disable, all settings will use the highest available patch version.

    向前復原行為也可以在專案檔案屬性、執行時間配置檔案屬性和環境變數中設定。Roll forward behavior can also be configured in a project file property, a run-time configuration file property, and an environment variable. 如需詳細資訊,請參閱 主要版本執行時間向前復原。For more information, see Major-version runtime roll forward.

  • --roll-forward-on-no-candidate-fx <N>****適用于 .Net Core 2.X SDK。--roll-forward-on-no-candidate-fx <N> Available in .NET Core 2.x SDK.

    在必要的共用架構無法使用時定義行為。Defines behavior when the required shared framework is not available. N 可以是:N can be:

    • 0 - 對次要版本也停用向前復原。0 - Disable even minor version roll forward.
    • 1 - 對次要版本向前復原,主要版本則不。1 - Roll forward on minor version, but not on major version. 此為預設行為。This is the default behavior.
    • 2 - 對次要及主要版本向前復原。2 - Roll forward on minor and major versions.

    如需詳細資訊,請參閱向前復原For more information, see Roll forward.

    從 .NET Core 3.0 開始,此選項會被取代 --roll-forward ,而且應該改用該選項。Starting with .NET Core 3.0, this option is superseded by --roll-forward, and that option should be used instead.

  • --fx-version <VERSION>

    要用來執行應用程式的 .NET 執行階段版本。Version of the .NET runtime to use to run the application.

    此選項會覆寫應用程式檔案中第一個架構參考的版本 .runtimeconfig.jsonThis option overrides the version of the first framework reference in the application's .runtimeconfig.json file. 這表示如果只有一個架構參考,它只會如預期般運作。This means it only works as expected if there's just one framework reference. 如果應用程式有一個以上的架構參考,則使用這個選項可能會導致錯誤。If the application has more than one framework reference, using this option may cause errors.

dotnet 命令dotnet commands

一般General

命令Command 函式Function
dotnet builddotnet build 建立 .NET 應用程式。Builds a .NET application.
dotnet build-serverdotnet build-server 與組建所啟動的伺服器互動。Interacts with servers started by a build.
dotnet cleandotnet clean 清除組建輸出。Clean build outputs.
dotnet helpdotnet help 顯示命令更詳細的線上文件。Shows more detailed documentation online for the command.
dotnet migratedotnet migrate 將有效的 Preview 2 專案移轉至 .NET Core SDK 1.0 專案。Migrates a valid Preview 2 project to a .NET Core SDK 1.0 project.
dotnet msbuilddotnet msbuild 提供對 MSBuild 命令列的存取。Provides access to the MSBuild command line.
dotnet newdotnet new 初始化指定範本的 C# 或 F# 專案。Initializes a C# or F# project for a given template.
dotnet packdotnet pack 建立您程式碼的 NuGet 套件。Creates a NuGet package of your code.
dotnet publishdotnet publish 發行 .NET 與 Framework 相依的應用程式或獨立應用程式。Publishes a .NET framework-dependent or self-contained application.
dotnet restoredotnet restore 還原所指定應用程式的相依性。Restores the dependencies for a given application.
dotnet rundotnet run 從原始檔執行應用程式。Runs the application from source.
dotnet slndotnet sln 要在方案檔中新增、移除及列出專案的選項。Options to add, remove, and list projects in a solution file.
dotnet storedotnet store 在執行階段套件存放區中儲存組件。Stores assemblies in the runtime package store.
dotnet testdotnet test 使用測試執行器執行測試。Runs tests using a test runner.

專案參考Project references

命令Command 函式Function
dotnet add referencedotnet add reference 新增專案參考。Adds a project reference.
dotnet list referencedotnet list reference 列出專案參考。Lists project references.
dotnet remove referencedotnet remove reference 移除專案參考。Removes a project reference.

NuGet 套件NuGet packages

命令Command 函式Function
dotnet add packagedotnet add package 新增 NuGet 套件。Adds a NuGet package.
dotnet remove packagedotnet remove package 移除 NuGet 套件。Removes a NuGet package.

NuGet 命令NuGet commands

命令Command 函式Function
dotnet nuget deletedotnet nuget delete 從伺服器刪除或取消列出套件。Deletes or unlists a package from the server.
dotnet nuget pushdotnet nuget push 將套件推送至伺服器並發行。Pushes a package to the server and publishes it.
dotnet nuget localsdotnet nuget locals 清除或列出本機 NuGet 資源,例如 http-request 快取、暫時快取,或整部電腦的全域套件資料夾。Clears or lists local NuGet resources such as http-request cache, temporary cache, or machine-wide global packages folder.
dotnet nuget add sourcedotnet nuget add source 新增 NuGet 來源。Adds a NuGet source.
dotnet nuget disable sourcedotnet nuget disable source 停用 NuGet 來源。Disables a NuGet source.
dotnet nuget enable sourcedotnet nuget enable source 啟用 NuGet 來源。Enables a NuGet source.
dotnet nuget list sourcedotnet nuget list source 列出所有已設定的 NuGet 來源。Lists all configured NuGet sources.
dotnet nuget remove sourcedotnet nuget remove source 移除 NuGet 來源。Removes a NuGet source.
dotnet nuget update sourcedotnet nuget update source 更新 NuGet 來源。Updates a NuGet source.

全域、工具路徑和本機工具命令Global, tool-path, and local tools commands

工具是從 NuGet 套件安裝的主控台應用程式,會從命令提示字元叫用。Tools are console applications that are installed from NuGet packages and are invoked from the command prompt. 您可以自行撰寫工具或安裝協力廠商所撰寫的工具。You can write tools yourself or install tools written by third parties. 工具也稱為「通用工具」、「工具路徑工具」和「本機工具」。Tools are also known as global tools, tool-path tools, and local tools. 如需詳細資訊,請參閱 .net 工具總覽For more information, see .NET tools overview. 從 .NET Core SDK 2.1 開始,可以使用全域和工具路徑工具。Global and tool-path tools are available starting with .NET Core SDK 2.1. 從 .NET Core SDK 3.0 開始,可以使用本機工具。Local tools are available starting with .NET Core SDK 3.0.

命令Command 函式Function
dotnet tool installdotnet tool install 在您的電腦上安裝工具。Installs a tool on your machine.
dotnet tool listdotnet tool list 列出電腦上目前已安裝的所有全域、工具路徑或本機工具。Lists all global, tool-path, or local tools currently installed on your machine.
dotnet 工具搜尋dotnet tool search 搜尋 NuGet.org 是否有在其名稱或中繼資料中具有指定之搜尋詞彙的工具。Searches NuGet.org for tools that have the specified search term in their name or metadata.
dotnet tool uninstalldotnet tool uninstall 從您的電腦卸載工具。Uninstalls a tool from your machine.
dotnet tool updatedotnet tool update 更新電腦上所安裝的工具。Updates a tool that is installed on your machine.

其他工具Additional tools

從 .NET Core SDK 2.1.300 開始,使用的一些工具現在僅適用于以專案為基礎的工具, DotnetCliToolReference 現在已可在 .NET SDK 中使用。Starting with .NET Core SDK 2.1.300, a number of tools that were available only on a per project basis using DotnetCliToolReference are now available as part of the .NET SDK. 這些工具列於下列資料表中:These tools are listed in the following table:

工具Tool 函式Function
dev-certsdev-certs 建立及管理開發憑證。Creates and manages development certificates.
efef Entity Framework Core 命令列工具。Entity Framework Core command-line tools.
sql-cachesql-cache SQL Server 快取命令列工具。SQL Server cache command-line tools.
user-secretsuser-secrets 管理開發使用者祕密。Manages development user secrets.
watch 啟動會在檔案變更時執行命令的檔案監看員。Starts a file watcher that runs a command when files change.

如需每個工具的詳細資訊,請鍵入 dotnet <tool-name> --helpFor more information about each tool, type dotnet <tool-name> --help.

範例Examples

建立新的 .NET 主控台應用程式:Create a new .NET console application:

dotnet new console

建置所指定目錄中的專案和其相依性:Build a project and its dependencies in a given directory:

dotnet build

執行應用程式:Run an application:

dotnet myapp.dll

環境變數Environment variables

  • DOTNET_ROOT, DOTNET_ROOT(x86)DOTNET_ROOT, DOTNET_ROOT(x86)

    指定 .NET 執行時間的位置(如果未安裝在預設位置)。Specifies the location of the .NET runtimes, if they are not installed in the default location. Windows 上的預設位置為 C:\Program Files\dotnetThe default location on Windows is C:\Program Files\dotnet. Linux 和 macOS 上的預設位置為 /usr/share/dotnetThe default location on Linux and macOS is /usr/share/dotnet. 此環境變數只會在透過產生的可執行檔( (apphosts) )執行應用程式時使用。This environment variable is used only when running apps via generated executables (apphosts). DOTNET_ROOT(x86) 當在64位作業系統上執行32位可執行檔時,會改用DOTNET_ROOT(x86) is used instead when running a 32-bit executable on a 64-bit OS.

  • NUGET_PACKAGES

    全域套件資料夾。The global packages folder. 如果未設定,預設為 ~/.nuget/packages (Unix) 或 %userprofile%\.nuget\packages (Windows)。If not set, it defaults to ~/.nuget/packages on Unix or %userprofile%\.nuget\packages on Windows.

  • DOTNET_SERVICING

    指定載入執行階段時,共用主機所使用的服務索引位置。Specifies the location of the servicing index to use by the shared host when loading the runtime.

  • DOTNET_NOLOGO

    指定是否要在第一次執行時顯示 .NET 歡迎畫面和遙測訊息。Specifies whether .NET welcome and telemetry messages are displayed on first run. 設定為可將 true 這些訊息靜音 (值 true1yes 接受) 或設定為, false 以允許 (值 false0no 接受) 。Set to true to mute these messages (values true, 1, or yes accepted) or set to false to allow (values false, 0, or no accepted). 如果未設定,預設值為, false 而訊息將會在第一次執行時顯示。If not set, the default is false and the messages will be displayed on first run. 此旗標不會影響遙測 (請參閱退出傳送 DOTNET_CLI_TELEMETRY_OPTOUT 遙測) 。This flag has no effect on telemetry (see DOTNET_CLI_TELEMETRY_OPTOUT for opting out of sending telemetry).

  • DOTNET_CLI_TELEMETRY_OPTOUT

    指定是否收集 .NET 工具使用量的相關資料,並將其傳送給 Microsoft。Specifies whether data about the .NET tools usage is collected and sent to Microsoft. 設為 true 以選擇加入遙測功能 (可接受的值為 true1yes)。Set to true to opt-out of the telemetry feature (values true, 1, or yes accepted). 否則,請設為 false 以選擇退出遙測功能 (可接受的值為 false0no)。Otherwise, set to false to opt into the telemetry features (values false, 0, or no accepted). 如果未設定,預設值為 false,且遙測功能會處於作用狀態。If not set, the default is false and the telemetry feature is active.

  • DOTNET_MULTILEVEL_LOOKUP

    指定是否從全域位置解析 .NET 執行時間、共用架構或 SDK。Specifies whether .NET runtime, shared framework, or SDK are resolved from the global location. 如果未設定,則預設為 1 (邏輯 true) 。If not set, it defaults to 1 (logical true). 設定為 0 (邏輯 false) 不會從全域位置解析,並且具有隔離的 .net 安裝。Set to 0 (logical false) to not resolve from the global location and have isolated .NET installations. 如需多層級查閱的詳細資訊,請參閱 Multi-level SharedFX Lookup (多層級 SharedFX 查閱)。For more information about multi-level lookup, see Multi-level SharedFX Lookup.

  • DOTNET_ROLL_FORWARD從 .Net Core 3.x 開始提供。DOTNET_ROLL_FORWARD Available starting with .NET Core 3.x.

    判斷向前復原行為。Determines roll forward behavior. 如需詳細資訊,請參閱本文稍 --roll-forward 早的選項。For more information, see the --roll-forward option earlier in this article.

  • DOTNET_ROLL_FORWARD_TO_PRERELEASE從 .Net Core 3.x 開始提供。DOTNET_ROLL_FORWARD_TO_PRERELEASE Available starting with .NET Core 3.x.

    如果設定為 1 (啟用) ,則可從發行版本向前復原至發行前版本。If set to 1 (enabled), enables rolling forward to a pre-release version from a release version. 依預設 (0 -disabled) ,當要求 .net 執行時間的發行版本時,向前復原只會考慮已安裝的發行版本。By default (0 - disabled), when a release version of .NET runtime is requested, roll-forward will only consider installed release versions.

    如需詳細資訊,請參閱向前復原For more information, see Roll forward.

  • DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX適用于 .Net Core 2.x。DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX Available in .NET Core 2.x.

    如果設定為 0,將停用次要版本向前復原。Disables minor version roll forward, if set to 0. 如需詳細資訊,請參閱向前復原For more information, see Roll forward.

    這項設定已在 .NET Core 3.0 中取代 DOTNET_ROLL_FORWARDThis setting is superseded in .NET Core 3.0 by DOTNET_ROLL_FORWARD. 您應改為使用新的設定。The new settings should be used instead.

  • DOTNET_CLI_UI_LANGUAGE

    使用地區設定值(例如)設定 CLI UI 的語言 en-usSets the language of the CLI UI using a locale value such as en-us. 支援的值與 Visual Studio 的值相同。The supported values are the same as for Visual Studio. 如需詳細資訊,請參閱 Visual Studio 安裝檔中的變更安裝程式語言一節。For more information, see the section on changing the installer language in the Visual Studio installation documentation. 適用 .NET resource manager 規則,因此您不需要挑選完全相符的結果, — 您也可以在樹狀目錄中挑選子系 CultureInfoThe .NET resource manager rules apply, so you don't have to pick an exact match—you can also pick descendants in the CultureInfo tree. 例如,如果您將它設定為 fr-CA ,CLI 會尋找並使用 fr 翻譯。For example, if you set it to fr-CA, the CLI will find and use the fr translations. 如果您將它設定為不支援的語言,CLI 會切換回英文。If you set it to a language that is not supported, the CLI falls back to English.

  • DOTNET_DISABLE_GUI_ERRORS

    啟用 GUI 的已產生可執行檔-停用對話方塊快顯視窗,通常會針對某些錯誤類別顯示。For GUI-enabled generated executables - disables dialog popup, which normally shows for certain classes of errors. 它只會 stderr 在這些情況下寫入和結束。It only writes to stderr and exits in those cases.

  • DOTNET_ADDITIONAL_DEPS

    相當於 CLI 選項 --additional-depsEquivalent to CLI option --additional-deps.

  • DOTNET_RUNTIME_ID

    覆寫偵測到的 RID。Overrides the detected RID.

  • DOTNET_SHARED_STORE

    「共用存放區」的位置,在某些情況下,元件解析會回復為。Location of the "shared store" which assembly resolution falls back to in some cases.

  • DOTNET_STARTUP_HOOKS

    要載入和執行啟動攔截的元件清單。List of assemblies to load and execute startup hooks from.

  • DOTNET_BUNDLE_EXTRACT_BASE_DIR從 .Net Core 3.x 開始提供。DOTNET_BUNDLE_EXTRACT_BASE_DIR Available starting with .NET Core 3.x.

    指定在執行單一檔案應用程式之前解壓縮的目錄。Specifies a directory to which a single-file application is extracted before it is executed.

    如需詳細資訊,請參閱 單一檔案可執行檔。For more information, see Single-file executables.

  • COREHOST_TRACE, COREHOST_TRACEFILE, COREHOST_TRACE_VERBOSITYCOREHOST_TRACE, COREHOST_TRACEFILE, COREHOST_TRACE_VERBOSITY

    控制來自裝載元件的診斷追蹤,例如 dotnet.exehostfxrhostpolicyControls diagnostics tracing from the hosting components, such as dotnet.exe, hostfxr, and hostpolicy.

    • COREHOST_TRACE=[0/1] -預設為 0 -追蹤已停用。COREHOST_TRACE=[0/1] - default is 0 - tracing disabled. 如果設定為 1 ,則會啟用診斷追蹤。If set to 1, diagnostics tracing is enabled.
    • COREHOST_TRACEFILE=<file path> -只有在啟用追蹤時,才會有作用 COREHOST_TRACE=1COREHOST_TRACEFILE=<file path> - only has effect if tracing is enabled via COREHOST_TRACE=1. 設定時,追蹤資訊會寫入至指定的檔案,否則會將追蹤資訊寫入至 stderrWhen set, the tracing information is written to the specified file, otherwise the tracing information is written to stderr. 從 .NET Core 3.x 開始提供。Available starting with .NET Core 3.x.
    • COREHOST_TRACE_VERBOSITY=[1/2/3/4] -預設值為 4COREHOST_TRACE_VERBOSITY=[1/2/3/4] - default is 4. 只有透過啟用追蹤時,才會使用此設定 COREHOST_TRACE=1The setting is used only when tracing is enabled via COREHOST_TRACE=1. 從 .NET Core 3.x 開始提供。Available starting with .NET Core 3.x.
      • 4 -寫入所有追蹤資訊4 - all tracing information is written
      • 3 -只寫入參考、警告和錯誤訊息3 - only informational, warning and error messages are written
      • 2 -只寫入警告和錯誤訊息2 - only warning and error messages are written
      • 1 -只寫入錯誤訊息1 - only error messages are written

    取得應用程式啟動詳細追蹤資訊的一般方式是設定,然後 COREHOST_TRACE=1 COREHOST_TRACEFILE=host_trace.txt 執行應用程式。The typical way to get detailed trace information about application startup is to set COREHOST_TRACE=1 and COREHOST_TRACEFILE=host_trace.txt and then run the application. host_trace.txt將會在目前目錄中建立含有詳細資訊的新檔案。A new file host_trace.txt will be created in the current directory with the detailed information.

另請參閱See also