[Bug] Microsoft.Identity.Client.NativeInterop Incompatibility with Native AOT compilation
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.ClientMicrosoft.Identity.Client.BrokerMicrosoft.IdentityModel.AbstractionsMicrosoft.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
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.
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
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
this issue has been discussed since April-16th with the MSAL team. We would love this to be prioritized.