🔑 基本命令
命令 功能 常用參數
dotnet new 建立新專案或檔案範本 --list 列出範本、--name 指定名稱、--output 指定輸出路徑
dotnet build 編譯專案與相依性 --configuration (Debug/Release)、--verbosity (quiet/minimal/normal/detailed/diagnostic)
dotnet run 編譯並執行專案 --project 指定專案檔、--configuration、--urls 指定執行網址
dotnet test 執行測試 --filter 過濾測試、--logger 指定輸出格式
dotnet restore 還原 NuGet 套件 --force 強制還原、--no-cache 不使用快取
dotnet clean 清除編譯輸出 無特別參數
dotnet publish 發佈專案 --configuration、--runtime (指定目標平台)、--self-contained

📦 套件與工具管理
命令 功能 常用參數
dotnet add package 新增 NuGet 套件 --version 指定版本
dotnet remove package 移除 NuGet 套件 無特別參數
dotnet list package 列出專案套件 --outdated 顯示過期套件
dotnet tool install 安裝 .NET CLI 工具 --global 全域安裝、--local 專案安裝
dotnet tool update 更新工具 同上
dotnet tool list 列出已安裝工具 --global 或 --local

🛠️SDK 與環境
命令 功能
dotnet --info 顯示 .NET SDK 與 Runtime 資訊
dotnet --list-sdks 列出已安裝的 SDK
dotnet --list-runtimes 列出已安裝的 Runtime
dotnet help 或 dotnet -h 顯示命令說明

🌐 進階參數

通用選項 (幾乎所有命令都支援) :

  • --verbosity <level> : 輸出詳細程度
  • --configuration <Debug | Release> : 指定編譯模式
  • --framework <TFM> : 指定目標框架 (例如 net6.0)
  • --runtime <RID> : 指定執行平台 (例如 win-x64, linux-arm64)
  • --output <dir> : 指定輸出目錄
創作者介紹
創作者 mitblog 的頭像
mitblog

香腸炒章魚

mitblog 發表在 痞客邦 留言(0) 人氣(11)