1. 程式人生 > >dotnet cli 5.0 新特性——dotnet tool search

dotnet cli 5.0 新特性——dotnet tool search

# dotnet cli 5.0 新特性——dotnet tool search ## Intro .NET 5.0 SDK 的釋出,給 dotnet cli 引入了一個新的特性,`dotnet tool search`,主要用於搜尋 Nuget 上的 dotnet tool,這個命令會搜尋 tool 的名稱以及一些元資料, titles, descriptions, 和 tags ## Search ### Synopsis > dotnet tool search [--detail] [--prerelease] > [--skip ] [--take ] > > dotnet tool search -h|--help 可以通過 `dotnet tool search -h` 檢視支援的引數,支援的引數如下: - **`--detail`** 顯示詳細結果 - **`--prerelease`** 是否包含預覽版 - **`--skip `** 跳過前面多少條資料,用於分頁 - **`--take `** 指定要返回的資料條數,用於分頁查詢 ### Examples 來看幾個簡單的示例: 使用 `dotnet tool search ` 進行最基本的搜尋, 使用 `dotnet tool search --skip --take ` 來進行分頁查詢 ![](https://img2020.cnblogs.com/blog/489462/202101/489462-20210126232000018-1108843325.png) 使用 `dotnet tool search --take 1 --detail` 查詢詳細資訊 ![](https://img2020.cnblogs.com/blog/489462/202101/489462-20210126231927765-1797568363.png) ## More 這個功能從 .NET 5.0 SDK 之後才支援,它的實現方式倒是很簡單,直接呼叫了 Nuget 的介面,通過 `packageType=dotnettool` 只查詢 dotnet tool 用抓包工具抓個包看看,search 的時候做了什麼,search 的時候會呼叫 nuget 的介面,介面呼叫情況如下: ![](https://img2020.cnblogs.com/blog/489462/202101/489462-20210126233743636-1573464557.png) 有了這個我們即使不完全記得 package tool 的型別,我們也可以通過命令進行查詢,方便了很多 ## References - https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-tool-search