前言
開發環境日積月累,安裝了不少 SDK 版本,用不到也很佔空間,於是到了該清理的時候
目前我的機器存在的版本
Environment
- Windows 10
安裝 dotnet-core-unistall 工具
- 下載 msi 檔案: https://github.com/dotnet/cli-lab/releases
- .NET Core Uninstall Tool 文件: https://aka.ms/dotnet-core-uninstall-docs
- DotNet Core Uninstall v1.1.122401
安裝完 .NET Core Uninstall Tool 後,開啟 PowerShell 切換到 C:\Program Files (x86)\dotnet-core-uninstall
目錄
cd "C:\Program Files (x86)\dotnet-core-uninstall"
列出可移除的 dotnet core 版本
.\dotnet-core-uninstall list
有被 Visual Studio 使用的版本也會標記出來,這部分我要保留版本號的資訊
dry-run / whatif
在實際移除前,可用 dry-run 或 whatif 來看一下執行後會移除的版本
.\dotnet-core-uninstall dry-run [option] [VERSION]
.\dotnet-core-uninstall whatif [option] [VERSION]
移除僅特定版本 SDK
移除除了指定版本外的 SDK
把 dry-run 或 whatif 改成 remove 則會真的執行移除動作 (PowerShell 需使用系統管理員身分執行)
因為我要移除掉 Visual Studio 有使用以外的版本所以列出要保留的版本號,並加上 --all-but
的選項
.\dotnet-core-uninstall remove --sdk --all-but 2.1.202 2.1.513 2.1.802 2.2.104
刪除版本之前,也會再詢問是否確定要移除,執行後就會列出一個個被移除的版本
清掉之後僅留下的 SDK 版本
重新釋放掉不少空間