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

[Bug] Microsoft.Identity.Client.NativeInterop Incompatibility with Native AOT compilation

Open HotCakeX opened this issue 8 months ago • 1 comments

Library version used

0.18.1 for Nativeinterop and 4.70.1 for identity client package

.NET version

.NET 9

Scenario

PublicClient - desktop app

Is this a new or an existing app?

The app is in production, and I have upgraded to a new version of MSAL

Issue description and reproduction steps

I get an error when i compile my Native AOT app that uses the following packages:

  • Microsoft.Identity.Client
  • Microsoft.Identity.Client.Broker
  • Microsoft.IdentityModel.Abstractions
  • Microsoft.Identity.Client.NativeInterop

I always use the latest version of all of them.

IL3000 error:

Microsoft.Identity.Client.NativeInterop.Platform.GetExecutingAssemblyDirectory(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.


This doesn't fix it either (already tried)

 <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>

Relevant code snippets


Expected behavior

I expect it to work and compile successfully for Native AOT.

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

No response

HotCakeX avatar Apr 06 '25 10:04 HotCakeX

Btw clicking on "Source repository" or "Project website" in the NuGet page leads to this page => https://github.com/AzureAD/microsoft-authentication-library-for-cpp

which doesn't exist or is a private repository.

HotCakeX avatar Apr 06 '25 10:04 HotCakeX

This issue is also negatively impacting https://github.com/azure/azure-mcp for VS Code CoPilot and GitHub CoPilot scenarios (unnecessarily large size on disk due to .NET AOT violations in the implementation).

/cc @anuchandy

joshfree avatar Jun 25 '25 17:06 joshfree

We really need to get this fixed as soon as reasonably possible (August release) so we can hit our package size goals (.NET AOT Trimming) for the Azure MCP Server

joshfree avatar Jul 25 '25 17:07 joshfree

this issue has been discussed since April-16th with the MSAL team. We would love this to be prioritized.

joshfree avatar Jul 25 '25 17:07 joshfree