microsoft-authentication-library-for-dotnet icon indicating copy to clipboard operation
microsoft-authentication-library-for-dotnet copied to clipboard

[Feature Request] Add net6 and net6-windows target

Open pmaytak opened this issue 1 year ago • 2 comments

Goal: Find a solution for how to add net6 target to allow the use of System.Text.Json and IL trimming. Problem:

  • Current net6-winX apps reference net5-winX MSAL, which provides old WAM and embedded webview. After adding net6 MSAL target, the same apps end up targeting net6 MSAL, which does not have built in WAM and embedded webview implementations.
  • Current net6 and net6-win apps use netcoreapp2.1 MSAL. netcore2.1 target does not provide WAM or embedded webview out of the box. netcore3.1 apps can reference MSAL.Desktop package to enable those features. However, since MSAL.Desktop references Windows features, net6 apps cannot reference it.

Current target platform compatibility and Windows UI component support (for related and newer platforms):

App targets MSAL target used WAM Embedded Browser
net6 netcore2.1 Error and cannot use MSAL.Desktop Error and cannot use MSAL.Desktop
net6-win netcore2.1 Error and cannot use MSAL.Desktop Error and cannot use MSAL.Desktop
net6-winX net5-winX Old WAM Works
net5 netcore2.1 Error and cannot use MSAL.Desktop Error and cannot use MSAL.Desktop
net5-win netcore2.1 Error and cannot use MSAL.Desktop Error and cannot use MSAL.Desktop
net5-winX net5-winX Old WAM Works
netcore2.1-3.1 netcore2.1 Error; use old WAM via MSAL.Desktop Error; use MSAL.Desktop

Note: System browser is available on all platforms.

Useful tool: Get Nearest Framework References: .NET 5 design doc, and specifically compatibility/precedence section .NET 6 design doc

Also to note, the design doc specifies that net6.0 adds both, NET5_0 and NET6_0 preprocessor flags, but in my testing, net6.0 only adds the NET6_0 flag.

pmaytak avatar Sep 17 '22 02:09 pmaytak

This issue is actually pretty big when using sampling code for a Microsoft Graph it requires using Microsoft.Identity.Client.Desktop; which makes .WithWindowsBroker(true) impossible with C# 8/.net 6.

ziron999o365 avatar Sep 18 '22 21:09 ziron999o365

@ziron999o365 - please use new broker preview experience, which does not require Microsoft.identity.Client.Desktop - see https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/wam

@pmaytak - you already added explicit support for net6. For windows components, users will need to use WAM preview. Closing, please reopen if you disagree.

bgavrilMS avatar Sep 19 '22 14:09 bgavrilMS

Moving to blocked status until we decide on a proper way to introduce this change, which depends on deprecating old WAM / GAing new WAM.

pmaytak avatar Sep 29 '22 02:09 pmaytak

.NET 5 has now been fully deprecated and is past end of life support. It's not clear what but my whole team had net5 disappear from over this last week from our dev machines, potentially with the latest VS Update.

There is no straight forward way I can see to possible update to net6.0 without breaking. The table shared above shows one slice where you target net6.0 in your app but use net5.-windows target of MSAL. Is there special CSPROJ magic to override the version the library uses, if building for windows?

kyle-rader avatar Sep 29 '22 08:09 kyle-rader

@pmaytak @bgavrilMS Am I doing anything obviously wrong here: https://github.com/AzureAD/microsoft-authentication-cli/pull/154 ?

kyle-rader avatar Sep 29 '22 08:09 kyle-rader

Can we ship this as part 4.48 ?

bgavrilMS avatar Oct 28 '22 16:10 bgavrilMS