共用方式為


dotnet 工具更新

此文章適用於:✔️ .NET 6 SDK 與更新版本

名稱

dotnet tool update - 更新您電腦上的指定 .NET 工具

概要

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

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

dotnet tool update <PACKAGE_ID> --local
    [--add-source <SOURCE>] [--all] [--allow-downgrade]
    [--configfile <FILE>]
    [--disable-parallel] [--framework <FRAMEWORK>]
    [--ignore-failed-sources] [--interactive]
    [--no-cache] [--prerelease] [--source <SOURCE>]
    [--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 套件名稱/標識符。

    從 .NET 10.0.100 SDK 開始,請使用名稱/識別碼和分隔版本 @ 來更新 .NET 工具。

    您可以使用 dotnet tool list 命令來尋找套件名稱。

選項

  • --add-source <SOURCE>

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

  • --all

    更新所有工具。

  • --allow-downgrade

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

  • --configfile <FILE>

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

  • --disable-parallel

    避免平行還原多個專案。

  • --framework <FRAMEWORK>

    指定要更新工具 的目標架構

  • -g|--global

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

  • -?|-h|--help

    輸出有關如何使用命令的說明。

  • --ignore-failed-sources

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

  • --interactive

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

  • --local

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

  • --no-cache

    請勿快取套件和 HTTP 要求。

  • --prerelease

    包含發行前版本。

  • --source <SOURCE>

    指定 NuGet 套件的來源。

  • --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 開始,是指特定的 major.minor.patch 版本, --version 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@2.1.7*

    dotnetsay 全域工具更新為最新的修補程式版本 2.1.7。

  • dotnet tool update -g dotnetsay --version (2.0.0,2.1.7)

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

另請參閱