(NuGet CLI 更新命令) update command (NuGet CLI)

適用物件: 套件耗用量 • 支援的版本: 全部Applies to: package consumption • Supported versions: all

將專案中的所有套件 (使用 packages.config) 更新為最新可用版本。Updates all packages in a project (using packages.config) to their latest available versions. 建議您先執行「 還原 」,再執行 updateIt is recommended to run 'restore' before running the update. (若要更新個別套件,請使用 nuget install 但不指定版本號碼,在此情況下,NuGet 會安裝最新版本。 ) (To update an individual package, use nuget install without specifying a version number, in which case NuGet installs the latest version.)

注意: update 無法使用在 Mono (MAC OSX 或 Linux) 下執行的 CLI,或使用 PackageReference 格式時。Note: update does not work with the CLI running under Mono (Mac OSX or Linux) or when using the PackageReference format.

update 命令也會更新專案檔中的元件參考,前提是這些參考已存在。The update command also updates assembly references in the project file, provided those references already exist. 如果更新的封裝具有已加入的元件,則 會加入新的參考。If an updated package has an added assembly, a new reference is not added. 新的封裝相依性也不會新增其元件參考。New package dependencies also don't have their assembly references added. 若要在更新過程中包含這些作業,請使用封裝管理員 UI 或封裝管理員主控台更新 Visual Studio 中的套件。To include these operations as part of an update, update the package in Visual Studio using the Package Manager UI or the Package Manager Console.

此命令也可以用來使用 -self 旗標來更新 nuget.exe 本身。This command can also be used to update nuget.exe itself using the -self flag.

使用方式Usage

nuget update <configPath> [options]

其中 <configPath> 會識別列出專案相依性的 packages.config 或方案檔。where <configPath> identifies either a packages.config or solution file that lists the project's dependencies.

選項。Options

  • -ConfigFile

    要套用的 NuGet 設定檔。The NuGet configuration file to apply. 如果未指定, %AppData%\NuGet\NuGet.Config 則會使用 (Windows) 或 ~/.nuget/NuGet/NuGet.Config~/.config/NuGet/NuGet.Config (Mac/Linux) 。If not specified, %AppData%\NuGet\NuGet.Config (Windows), or ~/.nuget/NuGet/NuGet.Config or ~/.config/NuGet/NuGet.Config (Mac/Linux) is used.

  • -FileConflictAction [PromptUser, Overwrite, Ignore]

    當封裝中的檔案已經存在於目標專案時,指定預設動作。Specifies the default action when a file from a package already exists in the target project. 設定為 [ Overwrite 永遠覆寫檔案]。Set to Overwrite to always overwrite files. 設定為 Ignore 以略過檔案。Set to Ignore to skip files.

    PromptUser除非提供或,否則動作(預設值)會提示您輸入每個衝突的檔案 OverwriteAll IgnoreAll ,這些檔案將會套用到所有剩餘的檔案。The PromptUser action, the default, will prompt for each conflicting file unless OverwriteAll or IgnoreAll is provided, which will apply to all remaining files.

  • -ForceEnglishOutput

    * (3.5 +) * 使用不因文化特性而異的文化特性,強制執行 nuget.exe。(3.5+) Forces nuget.exe to run using an invariant, English-based culture.

  • -?|-help

    顯示命令的說明資訊。Displays help information for the command.

  • -Id

    指定要更新之套件識別碼的清單。Specifies a list of package IDs to update.

  • -MSBuildPath

    * (4.0 +) * 指定要搭配命令使用的 MSBuild 路徑,優先順序高於 -MSBuildVersion(4.0+) Specifies the path of MSBuild to use with the command, taking precedence over -MSBuildVersion.

  • -MSBuildVersion

    * (3.2 +) * 指定要搭配此命令使用的 MSBuild 版本。(3.2+) Specifies the version of MSBuild to be used with this command. 支援的值為4、12、14、15.1、15.3、15.4、15.5、15.6、15.7、15.8、15.9。Supported values are 4, 12, 14, 15.1, 15.3, 15.4, 15.5, 15.6, 15.7, 15.8, 15.9. 依預設,會挑選路徑中的 MSBuild,否則會預設為 MSBuild 的最高安裝版本。By default the MSBuild in your path is picked, otherwise it defaults to the highest installed version of MSBuild.

  • -NonInteractive

    抑制使用者輸入或確認的提示。Suppresses prompts for user input or confirmations.

  • -PreRelease

    允許更新為發行前版本。Allows updating to prerelease versions. 更新已安裝的發行前版本套件時,不需要此旗標。This flag is not required when updating prerelease packages that are already installed.

  • -RepositoryPath

    指定安裝封裝的本機資料夾。Specifies the local folder where packages are installed.

  • -Safe

    指定在安裝套件的主要和次要版本中,只會安裝具有最高版本的更新。Specifies that only updates with the highest version available within the same major and minor version as the installed package will be installed.

  • -Self

    更新為最新版本 nuget.exe;系統會忽略所有其他引數。Updates nuget.exe to the latest version; all other arguments are ignored.

  • -Source

    指定要用於更新的 Url) (套件來源的清單。Specifies the list of package sources (as URLs) to use for the updates. 如果省略,此命令會使用設定檔中提供的來源,請參閱 一般 NuGet設定。If omitted, the command uses the sources provided in configuration files, see Common NuGet configurations.

  • -Verbosity [normal|quiet|detailed]

    指定輸出中顯示的詳細資料量: normal (預設) 、 quietdetailedSpecifies the amount of detail displayed in the output: normal (the default), quiet, or detailed.

  • -Version

    與一個封裝識別碼搭配使用時,會指定要更新的封裝版本。When used with one package ID, specifies the version of the package to update.

另請參閱 環境變數Also see Environment variables

範例Examples

nuget update

# update packages installed in solution.sln, using MSBuild version 14.0 to load the solution and its project(s).
nuget update solution.sln -MSBuildVersion 14

nuget update -safe

nuget update -self