.NET 6新特性试用 | SDK工作负载
生活随笔
收集整理的這篇文章主要介紹了
.NET 6新特性试用 | SDK工作负载
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前言
為了應對.NET SDK能夠支持的程序集項目(例如iOS、Android、WASM)的不斷增長,從.NET 6開始,允許用戶僅安裝必要的SDK(例如ASP.NET Core),而不是一次性安裝“完整版”SDK。
這一切的基礎,是新的dotnet CLI命令——workload。
Demo
1.列表
首先,列出可安裝的工作負載:
dotnet?workload?search目前支持的工作負載如下:
Workload?ID???????????Description ------------------------------------------------------------------------------------------- android???????????????.NET?SDK?Workload?for?building?Android?applications. android-aot???????????.NET?SDK?Workload?for?building?Android?applications?with?AOT?support. ios???????????????????.NET?SDK?Workload?for?building?iOS?applications. maccatalyst???????????.NET?SDK?Workload?for?building?macOS?applications?with?MacCatalyst. macos?????????????????.NET?SDK?Workload?for?building?macOS?applications. maui??????????????????.NET?MAUI?SDK?for?all?platforms maui-android??????????.NET?MAUI?SDK?for?Android maui-desktop??????????.NET?MAUI?SDK?for?Desktop maui-ios??????????????.NET?MAUI?SDK?for?iOS maui-maccatalyst??????.NET?MAUI?SDK?for?Mac?Catalyst maui-mobile???????????.NET?MAUI?SDK?for?Mobile maui-windows??????????.NET?MAUI?SDK?for?Windows tvos??????????????????.NET?SDK?Workload?for?building?tvOS?applications. wasm-tools????????????.NET?WebAssembly?build?tools2.安裝
然后,下列命令安裝需要的工作負載:
dotnet?workload?install?{Workload_ID}我們安裝maui-windows試試:
dotnet?workload?install?maui-windows//輸出 Updated?advertising?manifest?microsoft.net.sdk.android. Updated?advertising?manifest?microsoft.net.sdk.ios. Updated?advertising?manifest?microsoft.net.sdk.macos. Updated?advertising?manifest?microsoft.net.workload.emscripten. Updated?advertising?manifest?microsoft.net.sdk.maccatalyst. Updated?advertising?manifest?microsoft.net.sdk.tvos. Updated?advertising?manifest?microsoft.net.workload.mono.toolchain. Updated?advertising?manifest?microsoft.net.sdk.maui. Installing?Microsoft.Maui.Core.Ref.win.6.0.101.2068-x64.msi?............?Done Installing?Microsoft.Maui.Core.Runtime.win.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Controls.Ref.win.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Controls.Runtime.win.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Essentials.Ref.win.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Essentials.Runtime.win.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.AspNetCore.Components.WebView.Maui.6.0.101.2068-x64.msi?....?Done Installing?Microsoft.Maui.Dependencies.6.0.101.2068-x64.msi?....?Done Installing?Microsoft.Maui.Controls.Build.Tasks.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Sdk.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Extensions.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Resizetizer.Sdk.6.0.101.2068-x64.msi?......?Done Installing?Microsoft.Maui.Templates.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Core.Ref.any.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Core.Runtime.any.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Controls.Ref.any.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Controls.Runtime.any.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Essentials.Ref.any.6.0.101.2068-x64.msi?.....?Done Installing?Microsoft.Maui.Essentials.Runtime.any.6.0.101.2068-x64.msi?.....?DoneSuccessfully?installed?workload(s)?maui-windows.可以看到,它并沒有安裝多余的SDK,比如Maui的android版本。
打開VS 2022,新建項目,已經可以創建MAUI項目了,默認情況下是沒有的:
3.更新
另外,你可以使用下列命令,將所有已安裝的SDK工作負載更新為最新版本:
dotnet?workload?update//輸出 Updated?advertising?manifest?microsoft.net.sdk.ios. Updated?advertising?manifest?microsoft.net.sdk.android. Updated?advertising?manifest?microsoft.net.sdk.macos. Updated?advertising?manifest?microsoft.net.workload.emscripten. Updated?advertising?manifest?microsoft.net.sdk.tvos. Updated?advertising?manifest?microsoft.net.sdk.maccatalyst. Updated?advertising?manifest?microsoft.net.sdk.maui. Updated?advertising?manifest?microsoft.net.workload.mono.toolchain.Successfully?updated?workload(s):?maui-windows.4.卸載
當然,你可以將已安裝的SDK工作負載卸載:
dotnet?workload?uninstall?maui-windows//輸出 Removing?workload?installation?record?for?maui-windows... Removing?Microsoft.AspNetCore.Components.WebView.Maui.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Controls.Build.Tasks.6.0.101.2068-x64.msi?....?Done Removing?Microsoft.Maui.Controls.Ref.any.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Controls.Ref.win.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Controls.Runtime.any.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Controls.Runtime.win.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Core.Ref.any.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Core.Ref.win.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Core.Runtime.any.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Core.Runtime.win.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Dependencies.6.0.101.2068-x64.msi?....?Done Removing?Microsoft.Maui.Essentials.Ref.any.6.0.101.2068-x64.msi?....?Done Removing?Microsoft.Maui.Essentials.Ref.win.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Essentials.Runtime.any.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Essentials.Runtime.win.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Extensions.6.0.101.2068-x64.msi?....?Done Removing?Microsoft.Maui.Resizetizer.Sdk.6.0.101.2068-x64.msi?....?Done Removing?Microsoft.Maui.Sdk.6.0.101.2068-x64.msi?.....?Done Removing?Microsoft.Maui.Templates.6.0.101.2068-x64.msi?....?DoneSuccessfully?uninstalled?workload(s):?maui-windows結論
可以將此功能理解為SDK的包管理器,保證我們始終安裝正確的SDK以及版本。
如果你覺得這篇文章對你有所啟發,請幫忙點個贊或者在看
總結
以上是生活随笔為你收集整理的.NET 6新特性试用 | SDK工作负载的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2021 .NET 开发者峰会顺利在网上
- 下一篇: 极简实用的Asp.NetCore模块化框