dotnet tool update

本文適用於: ✔️ .NET Core 3.1 SDK 與更新版本

名稱

dotnet tool update - 在您的機器上更新指定的 .NET 工具

概要

dotnet tool update <PACKAGE_ID> -g|--global
    [--add-source <SOURCE>] [--allow-downgrade]
    [--configfile <FILE>]
    [--disable-parallel] [--framework <FRAMEWORK>]
    [--ignore-failed-sources] [--interactive]
    [--no-cache] [--prerelease]
    [-v|--verbosity <LEVEL>] [--version <VERSION>]

dotnet tool update <PACKAGE_ID> --tool-path <PATH>
    [--add-source <SOURCE>] [--allow-downgrade]
    [--configfile <FILE>]
    [--disable-parallel] [--framework <FRAMEWORK>]
    [--ignore-failed-sources] [--interactive] 
    [--no-cache] [--prerelease]
    [-v|--verbosity <LEVEL>] [--version <VERSION>]

dotnet tool update <PACKAGE_ID> --local
    [--add-source <SOURCE>] [--allow-downgrade]
    [--configfile <FILE>]
    [--disable-parallel] [--framework <FRAMEWORK>]
    [--ignore-failed-sources] [--interactive]
    [--no-cache] [--prerelease]
    [--tool-manifest <PATH>]
    [-v|--verbosity <LEVEL>] [--version <VERSION>]

dotnet tool update -h|--help

描述

dotnet tool update 命令可讓您將電腦上的 .NET 工具更新為套件的最新穩定版本。 此命令會解除安裝並重新安裝工具,並有效地更新它。 若要使用此命令,請指定下列其中一個選項:

  • 若要更新已安裝在預設位置的全域工具,請使用 --global 選項
  • 若要更新已安裝在自訂位置的全域工具,請使用 --tool-path 選項。
  • 若要更新本機工具,請使用 --local 選項。

引數

  • PACKAGE_ID

    包含要更新之 .NET 全域工具的 NuGet 套件的名稱/識別碼。 您可以使用 dotnet tool list 命令來找到此套件名稱。

選項。

  • --add-source <SOURCE>

    新增其他 NuGet 套件來源以在安裝期間使用。 系統會平行存取摘要,而非按照優先順序逐一存取。 如果相同的套件和版本存在於多個摘要中,則最快速的摘要會勝出。 如需詳細資訊,請參閱安裝 NuGet 套件後會發生哪些情況?

  • --allow-downgrade

    允許在安裝或更新 .NET 工具套件時降級套件。 隱藏警告:「要求的版本 x.x.x 低於現有的 x.x.x 版」。

  • --configfile <FILE>

    要使用的 NuGet 組態檔 (nuget.config)。 若已指定,僅會使用此檔案中的設定。 若未指定,則將使用當前目錄中組態檔的階層。 如需詳細資訊,請參閱常見的 NuGet 組態

  • --disable-parallel

    避免平行還原多項專案。

  • --framework <FRAMEWORK>

    指定要更新其工具的目標 Framework

  • -g|--global

    指定更新適用於使用者範圍工具。 無法與 --tool-path 選項合併使用。 省略 --global--tool-path 會將要更新的工具指定為本機工具。

  • -?|-h|--help

    列印如何使用命令的描述。

  • --ignore-failed-sources

    將套件來源失敗視為警告。

  • --interactive

    可讓命令停止,並等候使用者輸入或進行動作。 例如完成驗證。

  • --local

    更新工具與本機工具資訊清單。 無法與 --global 選項或 --tool-path 選項合併使用。

  • --no-cache

    請勿快取套件和 HTTP 要求。

  • --prerelease

    包括發行前版本。

  • --tool-manifest <PATH>

    資訊清單檔的路徑。

  • --tool-path <PATH>

    指定安裝全域工具的位置。 PATH 可為絕對路徑或相對路徑。 無法與 --global 選項合併使用。 省略 --global--tool-path 會將要更新的工具指定為本機工具。

  • -v|--verbosity <LEVEL>

    設定命令的詳細資訊層級。 允許的值為 q[uiet]m[inimal]n[ormal]d[etailed]diag[nostic]。 如需詳細資訊,請參閱LoggerVerbosity

  • --version <VERSION>

    工具套件要更新至的版本範圍。 這無法用來降級版本,您必須先更新 uninstall 版本。

    從 .NET 8.0 開始,--version Major.Minor.Patch 是指特定 major.minor.patch 版本 (包括未列出的版本)。 若要改為取得特定 major.minor 版本的最新版本,請使用 --version Major.Minor.*

範例

  • dotnet tool update -g dotnetsay

    更新 dotnetsay 全域工具。

  • dotnet tool update dotnetsay --tool-path c:\global-tools

    從特定的 Windows 目錄中更新 dotnetsay 全域工具。

  • dotnet tool update dotnetsay --tool-path ~/bin

    從特定的 Linux/macOS 目錄中更新 dotnetsay 全域工具。

  • dotnet tool update dotnetsay

    更新為目前目錄安裝的 dotnetsay 本機工具。

  • dotnet tool update -g dotnetsay --version 2.0.*

    更新 dotnetsay 全域工具到最新的修補程式版本,其中主要版本為 2,次要版本為 0

  • dotnet tool update -g dotnetsay --version (2.0.*,2.1.4)

    更新 dotnetsay 全域工具到指定範圍 (> 2.0.0 && < 2.1.4) 內的最低版本,將會安裝版本 2.1.0 。 如需語意版本設定範圍的詳細資訊,請參閱 NuGet 封裝版本範圍

另請參閱