Microsoft.Identity.Client.Desktop

Giorgio Sfiligoi 391 Reputation points
2025-03-11T15:48:29.09+00:00

I successfully tested the sample https://github.com/Azure-Samples/ms-identity-dotnetcore-maui/tree/main/MauiAppBasic in .NET MAUI 8.0.

Now I would like to create my own project using the same technique.

To begin with, I created an empty project, then I started loading the required libraries. When I load Microsoft.Identity.Client.Desktop I get an error:

"The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so."

Indeed from document https://learn.microsoft.com/en-us/entra/msal/dotnet/acquiring-tokens/desktop-mobile/wam I learn that MAUI does not support this library; this leads me to two questions:

  1. How is that the sample compiles and runs without raising that error?
  2. How can I sort out this issue in my project?

Although my project is targeted to Android, I would like to have the multi-platform capability that in principle MAU offers.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2025-03-25T05:50:32.35+00:00

    Hello,

    On the NuGet Package page of Microsoft.Identity.Client, we can see the Included target framework(s), Windows platform is not supported.

    Please try to use "Microsoft.Identity.Client" and "Microsoft.Identity.Client.Extensions.Msal" as Bruce said.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.