Open anpin opened 2 months ago
I have tried to fork MSAL and align webview2 version with one referenced by Microsoft.WindowsAppSDK. Now the project fails to compile with the same Payload contains two or more files with the same destination path 'Microsoft.Web.WebView2.Core.dll'
ok after git clean -ffdx
it builds and starts, yet fails with the same error of Could not load file or assembly...
, but with an updated version of 1.0.2646.
Execution fails around here
I can invoke CoreWebView2Environment.GetAvailableBrowserVersionString()
method from the app code and it returns actual version string and I do see the webview2 assembly in the bin/Debug
One could try to use <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
until it's properly fixed
@FoggyFinder I had to fork, update the reference you have mentioned and build MSAL myself https://github.com/anpin/microsoft-authentication-library-for-dotnet/tree/fix/webview2
it works for me without forking with reference to <PackageReference Include="Microsoft.Web.WebView2" Version="1.0.864.35" NoWarn="NU1902, NU1605" />
but alas with aot enabled I get
ILCompiler.NativeAotFatalErrorException: ILC: error IL1013: Error processing '...\Roots.xml'. ---> Internal.TypeSystem.TypeSystemException+FileNotFoundException: Failed to load assembly 'Microsoft.Web.WebView2.Core.Projection' at Internal.TypeSystem.ThrowHelper.ThrowFileNotFoundException(ExceptionStringID, String) + 0x30
wasn't able to find workaround for that yet
Internal.TypeSystem.TypeSystemException+FileNotFoundException: Failed to load assembly 'Microsoft.Web.WebView2.Core.Projection'
I had to remove <type fullname="Microsoft.UI.Xaml.Markup.*" />
from TrimmerRootDescriptor
to get rid of this error
and now I get runtime exception when aot is enabled:
System.NotSupportedException: COM Interop requires ComWrapper instance registered for marshalling. at System.Runtime.InteropServices.ComWrappers.ComInterfaceForObject(Object instance) + 0x73 at System.Runtime.InteropServices.ComWrappers.ComInterfaceForObject(Object instance, Guid targetIID) + 0x20 at Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateCoreWebView2EnvironmentWithOptions(String, String, ICoreWebView2EnvironmentOptions, ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler) + 0xb3 at Microsoft.Web.WebView2.Core.CoreWebView2Environment.
d__3.MoveNext() + 0xc0
@manodasanW to resolve the AOT error above, is it a matter of getting the right way to reference a webview2 package or windowsappsdk, or are changes likely to be needed in the msal repo?
Based on the above stack, it doesn't look like the CsWinRT projected version of WebView2 is being used. That looks to be the netcoreapp3 version possibly? Not sure if that was intentional or not? With that said, WebView2 also hasn't updated yet to the CsWinRT version with AOT support, but I believe they will be soon for one of their upcoming releases.
Library version used
4.61.3
.NET version
8.0.204
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
MSAL 4.61.3 fails to compile targeting WinUI3 self-contained deployment with
Payload contains two or more files with the same destination path 'Microsoft.Web.WebView2.Core.dll'
Above error is fixed by using
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
see https://github.com/microsoft/microsoft-ui-xaml/issues/5689#issuecomment-2206866464. However authentication fails on runtime due to missing webview2 assembly as the version in Microsoft.WindowsAppSDK is newer than MSALIs there a way to override which version of webview should be used?
related to https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/3583 https://github.com/microsoft/microsoft-ui-xaml/issues/5689 https://github.com/microsoft/WindowsAppSDK/issues/2492
Relevant code snippets
No response
Expected behavior
No response
Identity provider
Azure B2C Basic Policy
Regression
No response
Solution and workarounds
No response