source 命令 (winget)source command (winget)


Windows 程序包管理器和 winget 工具目前为公共预览版,在正式发布前可能会进行重大修改。Windows Package Manager and the winget tool are in public preview and may be substantially modified before they are generally available. Microsoft 不对此处提供的信息作任何明示或默示的担保。Microsoft makes no warranties, express or implied, with respect to the information provided here.


source 命令目前仅供内部使用。The source command is currently for internal use only. 目前不支持其他源。Additional sources are not supported at this time.

winget 工具的 source 命令可管理 Windows 程序包管理器访问的存储库。The source command of the winget tool manages the repositories accessed by Windows Package Manager. 使用 source 命令,可以添加、删除、列出以及更新存储库。With the source command you can add, remove, list, and update the repositories.

源为你提供用于发现和安装应用程序的数据。A source provides the data for you to discover and install applications. 仅当你信任新源作为安全位置时才会添加该源。Only add a new source if you trust it as a secure location.


winget source \<sub command> \<options>



可使用以下参数。The following arguments are available.

参数Argument 说明Description
-?、--help-?, --help 获取有关此命令的更多帮助。Gets additional help on this command.

子命令Sub commands

源支持以下用于操作源的子命令。Source supports the following sub commands for manipulating the sources.

子命令Sub command 说明Description
addadd 添加一个新源。Adds a new source.
listlist 枚举已启用源的列表。Enumerates the list of enabled sources.
updateupdate 更新源。Updates a source.
删除remove 删除源。Removes a source.
resetreset 将 winget 重置回初始配置。Resets winget back to the initial configuration.


source 命令支持以下选项。The source command supports the following options.

选项Option 说明Description
-n、--name-n,--name 用于标识源的名称。The name to identify the source by.
-a、--arg-a,--arg 源的 URL 或 UNC。The URL or UNC of the source.
-t、--type-t,--type 源的类型。The type of source.
-?、--help-?, --help 获取有关此命令的更多帮助。Gets additional help on this command.


add 子命令可添加新源。The add sub command adds a new source. 此子命令需要“--name”选项和“name”参数。This sub command requires the --name option and the name argument.

用法:winget source add [-n, --name] \<name> [-a] \<url> [[-t] \<type>]Usage: winget source add [-n, --name] \<name> [-a] \<url> [[-t] \<type>]

示例:winget source add --name Contoso winget source add --name Contoso

add 子命令还支持可选的“type”参数。The add sub command also supports the optional type parameter. “type”参数向客户端传递它所连接的存储库类型。The type parameter communicates to the client what type of repository it is connecting to. 支持以下类型。The following types are supported.

类型Type 说明Description
Microsoft.PreIndexed.PackageMicrosoft.PreIndexed.Package 源 <default> 的类型。The type of source <default>.


list 子命令枚举当前已启用的源。the list sub command enumerates the currently enabled sources. 此子命令还提供特定源的详细信息。This sub-command also provides details on a specific source.

用法:winget source list [-n, --name] \<name>Usage: winget source list [-n, --name] \<name>

全部列出list all

list 子命令本身会显示受支持源的完整列表。The list sub-command by itself will reveal the complete list of supported sources. 例如:For example:

> C:\winget source list
> Name   Arg
> -----------------------------------------
> winget

列出源详细信息list source details

若要获取源的完整详细信息,请传入用于标识源的名称。In order to get complete details on the source, pass in the name used to identify the source. 例如:For example:

> C:\winget source list --name contoso  
> Name   : contoso  
> Type   : Microsoft.PreIndexed.Package  
> Arg    :  
> Data   : AppInstallerSQLiteIndex-int_g4ype1skzj3jy  
> Updated: 2020-4-14 17:45:32.000

Name 显示用于标识源的名称。Name displays the name to identify the source by. Type 显示存储库的类型。Type displays the type of repo. Arg 显示源使用的 URL 或路径。Arg displays the URL or path used by the source. Data 显示所使用的可选包名称(如果适用)。Data displays the optional package name used if appropriate. Updated 显示上次更新源的日期和时间。Updated displays the last date and time the source was updated.


update 子命令强制更新单个源或所有源。The update sub command forces an update to an individual source or for all.

用法:winget source update [-n, --name] \<name>usage: winget source update [-n, --name] \<name>

全部更新update all

update 子命令本身会请求并更新每个存储库。The update sub command by itself will request and update to each repo. 例如:C:\winget updateFor example: C:\winget update

更新源update source

update 子命令与“--name”选项结合使用可定向到单个源并对其进行更新。The update sub command combined with the --name option can direct and update to an individual source. 例如:C:\winget source update --name contosoFor example: C:\winget source update --name contoso


remove 子命令可删除源。The remove sub command removes a source. 此子命令需要“--name”选项和“name”参数才能标识源。This sub command requires the --name option and name argument in order to identify the source.

用法:winget source remove [-n, --name] \<name>Usage: winget source remove [-n, --name] \<name>

例如:winget source remove --name ContosoFor example: winget source remove --name Contoso


reset 子命令可将客户端重置回其原始配置。The reset sub-command resets the client back to its original configuration. reset 子命令可删除所有源并将源设置为默认值。The reset sub-command removes all sources and sets the source to the default. 仅在极少数情况下才使用此子命令。This sub command should only be used in rare cases.

用法:winget source resetUsage: winget source reset

例如:winget source resetFor example: winget source reset

默认存储库Default repository

Windows 程序包管理器会指定默认存储库。Windows Package Manager specifies a default repository. 可使用 list 命令标识该存储库。You can identify the repository by using the list command. 例如:winget source listFor example: winget source list