共用方式為


dotnet 套件搜尋

本文適用於: ✔️.NET 8.0.2xx SDK 及後續版本

名稱

dotnet package search - 搜尋 NuGet 套件。

概要

dotnet package search <SEARCH TERM> [--configfile <FILE>] [--exact-match] [--format <FORMAT OPTION>]
    [--interactive] [--prerelease] [--skip <NUMBER>] [--source <SOURCE>] [--take <NUMBER>]
    [--verbosity <VERBOSITY VALUE>]

dotnet package search -h|--help

Description

指令會 dotnet package search 搜尋 NuGet 套件。

Arguments

  • search terms

    指定搜尋詞以篩選結果。 利用這個參數搜尋符合所提供查詢的套件。 範例: dotnet package search json.

選項

  • --configfile <FILE>

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

  • --exact-match

    此選項會將搜尋範圍縮小至僅包含與指定搜尋詞完全匹配的套件,有效過濾掉部分匹配的套件。 它提供了所有可用版本的簡明清單。 --take原因與--skip選項可以忽略。 使用此選項顯示指定套件的所有可用版本。

  • --format

    格式選項為 tablejson。 預設值為 table

  • --interactive

    允許命令停止並等候使用者輸入或動作。 例如,若要完成驗證。

  • --prerelease

    允許顯示預發布套件。

  • --skip

    分頁時可以跳過的結果數量。 預設值為 0。

  • --source <SOURCE>

    搜尋套件來源。 你可以傳遞多個 ---source 選項來搜尋多個套件來源。

  • --take

    要傳回的結果數目。 預設值為 20。

  • -v|--verbosity <LEVEL>

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

  • -?|-h|--help

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

範例

  • 搜尋 NuGet.org 符合搜尋詞「Newtonsoft.Json」的套件,並將輸出呈現為最多 20 個套件的表格:

    dotnet package search Newtonsoft.Json --source https://api.nuget.org/v3/index.json
    
        Source: https://api.nuget.org/v3/index.json
        | Package ID                                  | Latest Version | Owners | Downloads       |
        |---------------------------------------------|----------------|--------|-----------------|
        | Newtonsoft.Json                             | 13.0.3         |        | 3,829,822,911   |
        |---------------------------------------------|----------------|--------|-----------------|
        | Newtonsoft.Json.Bson                        | 1.0.2          |        | 554,641,545     |
        |---------------------------------------------|----------------|--------|-----------------|
        | Newtonsoft.Json.Schema                      | 3.0.15         |        | 39,648,430      |
        |---------------------------------------------|----------------|--------|-----------------|
        | Microsoft.AspNetCore.Mvc.NewtonsoftJson     | 7.0.12         |        | 317,067,823     |
        |---------------------------------------------|----------------|--------|-----------------|
        ...
    
  • 搜尋 NuGet.org 符合搜尋詞「Newtonsoft.Json」的套件,並將輸出輸出為 json。

    dotnet package search Newtonsoft.Json --source https://api.nuget.org/v3/index.json --format json
    
        {
        "version": 2,
        "problems": [],
        "searchResult": [
            {
            "sourceName": "https://api.nuget.org/v3/index.json",
            "packages": [
                {
                "id": "Newtonsoft.Json",
                "latestVersion": "13.0.3",
                "totalDownloads": 4456137550,
                "owners": "dotnetfoundation, jamesnk, newtonsoft"
                },
                {
                "id": "Newtonsoft.Json.Bson",
                "latestVersion": "1.0.2",
                "totalDownloads": 655362732,
                "owners": "dotnetfoundation, jamesnk, newtonsoft"
                },
                {
                "id": "Newtonsoft.Json.Schema",
                "latestVersion": "3.0.15",
                "totalDownloads": 46062119,
                "owners": "jamesnk, newtonsoft"
                },
                {
                "id": "Microsoft.AspNetCore.Mvc.NewtonsoftJson",
                "latestVersion": "8.0.3",
                "totalDownloads": 372202749,
                "owners": "aspnet, dotnetframework, Microsoft"
                },
                {
                "id": "Newtonsoft.Json.Encryption",
                "latestVersion": "2.2.0",
                "totalDownloads": 113101,
                "owners": "simoncropp"
                }
            ]
            }
        ]
        }
    
  • NuGet.org 搜尋套件時,使用搜尋詞「Newtonsoft.Json」,只顯示兩個結果,且搜尋結果中跳過前幾個套件:

    dotnet package search Newtonsoft.Json --source https://api.nuget.org/v3/index.json --skip 1 --take 2
    
        Source: https://api.nuget.org/v3/index.json
        | Package ID                                  | Latest Version | Owners | Downloads       |
        |---------------------------------------------|----------------|--------|-----------------|
        | Newtonsoft.Json.Bson                        | 1.0.2          |        | 554,641,545     |
        | Newtonsoft.Json.Schema                      | 3.0.15         |        | 39,648,430      |
    
  • 搜尋完全符合「Newtonsoft.Json」的套件,並列出所有可用版本,忽略包含「Newtonsoft.Json」但名稱與描述不完全相符的套件:

    dotnet package search Newtonsoft.Json --source https://api.nuget.org/v3/index.json --exact-match
    
        Source: https://api.nuget.org/v3/index.json
        | Package ID                                  | Version | Owners | Downloads       |
        |---------------------------------------------|---------|--------|-----------------|
        | Newtonsoft.Json                             | 13.0.3  |        | 3,829,822,911   |