Skip to content
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
0adea97
update
DharshanBJ Jul 22, 2025
967bdbb
working
DharshanBJ Jul 23, 2025
d30aa7b
Code to create a seperate nuget for winui3
DharshanBJ Jul 24, 2025
6632314
builds fine
DharshanBJ Jul 24, 2025
0f190e7
clean-up
DharshanBJ Jul 24, 2025
74804c1
clean-up
DharshanBJ Jul 24, 2025
a79a5ba
working
DharshanBJ Jul 28, 2025
7c5396c
update
DharshanBJ Jul 28, 2025
3fa1303
clean-up
DharshanBJ Jul 29, 2025
01a14ef
clean-up
DharshanBJ Jul 29, 2025
2956b33
clean-up
DharshanBJ Jul 29, 2025
9b9dcd6
clean-up
DharshanBJ Jul 29, 2025
3d5a15e
clean-up
DharshanBJ Jul 29, 2025
67a3137
Merge branch 'main' into dharshanb/winui3Support
DharshanBJ Jul 29, 2025
cb3caeb
clean-up
DharshanBJ Jul 29, 2025
1fa4a78
clean-up
DharshanBJ Jul 29, 2025
4e7dd8b
clean-up
DharshanBJ Jul 29, 2025
fc24488
clean-up
DharshanBJ Jul 29, 2025
9205904
clean-up
DharshanBJ Jul 29, 2025
cfe6c59
clean-up
DharshanBJ Jul 29, 2025
82ba6ea
clean-up
DharshanBJ Jul 29, 2025
25911f8
clean-up
DharshanBJ Jul 29, 2025
790050b
update
DharshanBJ Jul 29, 2025
db14988
clean-up
DharshanBJ Jul 29, 2025
8be4d3e
clean-up
DharshanBJ Jul 29, 2025
6e7a475
clean-up
DharshanBJ Jul 29, 2025
a1f4f20
clean-up
DharshanBJ Jul 29, 2025
8ab32e2
clean-up
DharshanBJ Jul 29, 2025
510072b
update
DharshanBJ Jul 29, 2025
ccac18a
Merge branch 'main' into dharshanb/winui3Support
DharshanBJ Jul 29, 2025
b3d41f4
Revert changes to AuthCodeRequestComponent.cs and Microsoft.Identity.…
DharshanBJ Jul 30, 2025
f1bfbd6
Merge branch 'dharshanb/winui3Support' of https://github.com/AzureAD/…
DharshanBJ Jul 30, 2025
2818fba
Revert changes to AuthCodeRequestComponent.cs and Microsoft.Identity.…
DharshanBJ Jul 30, 2025
2db86dd
add test-app
DharshanBJ Jul 31, 2025
f70aea3
add test-app
DharshanBJ Jul 31, 2025
453b9c5
Handle winui3 parent window
DharshanBJ Aug 1, 2025
90ea83d
clean-up
DharshanBJ Aug 1, 2025
0b64613
delete testapp readme
DharshanBJ Aug 1, 2025
8a8bec3
Merge branch 'main' into dharshanb/winui3Support
DharshanBJ Aug 4, 2025
12183e8
update
DharshanBJ Aug 5, 2025
9d04d61
Merge branch 'dharshanb/winui3Support' of https://github.com/AzureAD/…
DharshanBJ Aug 5, 2025
1573262
add winforms test app
DharshanBJ Aug 5, 2025
29c1e13
add winforms app that goes through webview2 flow
DharshanBJ Aug 5, 2025
e00856e
update the IsWinUI3Window check
DharshanBJ Aug 5, 2025
601f574
Merge branch 'main' into dharshanb/winui3Support
DharshanBJ Aug 5, 2025
c1cd2f8
update
DharshanBJ Aug 5, 2025
e982a1a
Merge branch 'dharshanb/winui3Support' of https://github.com/AzureAD/…
DharshanBJ Aug 5, 2025
74b1d29
update
DharshanBJ Aug 5, 2025
48d9e77
update
DharshanBJ Aug 5, 2025
339bc82
update
DharshanBJ Jul 22, 2025
8457760
working
DharshanBJ Jul 23, 2025
5540066
Code to create a seperate nuget for winui3
DharshanBJ Jul 24, 2025
07010d4
builds fine
DharshanBJ Jul 24, 2025
39613e7
clean-up
DharshanBJ Jul 24, 2025
00b6493
clean-up
DharshanBJ Jul 24, 2025
6556838
working
DharshanBJ Jul 28, 2025
6fbf4dd
update
DharshanBJ Jul 28, 2025
440fdcc
clean-up
DharshanBJ Jul 29, 2025
63ed0b3
clean-up
DharshanBJ Jul 29, 2025
92d8193
clean-up
DharshanBJ Jul 29, 2025
d3213f4
clean-up
DharshanBJ Jul 29, 2025
149ad82
clean-up
DharshanBJ Jul 29, 2025
49d26cc
clean-up
DharshanBJ Jul 29, 2025
83b48f5
clean-up
DharshanBJ Jul 29, 2025
665a9fb
clean-up
DharshanBJ Jul 29, 2025
6ed9b5c
clean-up
DharshanBJ Jul 29, 2025
4df323a
clean-up
DharshanBJ Jul 29, 2025
44281c9
clean-up
DharshanBJ Jul 29, 2025
d4127f1
clean-up
DharshanBJ Jul 29, 2025
5f574b9
clean-up
DharshanBJ Jul 29, 2025
613c06b
update
DharshanBJ Jul 29, 2025
f2806d0
clean-up
DharshanBJ Jul 29, 2025
8796e91
clean-up
DharshanBJ Jul 29, 2025
1f4c77e
clean-up
DharshanBJ Jul 29, 2025
2a98fad
clean-up
DharshanBJ Jul 29, 2025
1508c61
clean-up
DharshanBJ Jul 29, 2025
faf9574
update
DharshanBJ Jul 29, 2025
0f36e41
Revert changes to AuthCodeRequestComponent.cs and Microsoft.Identity.…
DharshanBJ Jul 30, 2025
51cad56
Revert changes to AuthCodeRequestComponent.cs and Microsoft.Identity.…
DharshanBJ Jul 30, 2025
0a3ef3c
add test-app
DharshanBJ Jul 31, 2025
e384789
add test-app
DharshanBJ Jul 31, 2025
8a19b2d
Handle winui3 parent window
DharshanBJ Aug 1, 2025
974473d
clean-up
DharshanBJ Aug 1, 2025
eb51f12
delete testapp readme
DharshanBJ Aug 1, 2025
d76ec96
update
DharshanBJ Aug 5, 2025
a524b23
add winforms test app
DharshanBJ Aug 5, 2025
5a96d29
add winforms app that goes through webview2 flow
DharshanBJ Aug 5, 2025
fcae881
update the IsWinUI3Window check
DharshanBJ Aug 5, 2025
00d4537
update
DharshanBJ Aug 5, 2025
7b11e68
update
DharshanBJ Aug 5, 2025
7e54e7b
update
DharshanBJ Aug 5, 2025
0b33cf4
Address comments
DharshanBJ Aug 21, 2025
58e3cc6
merge update
DharshanBJ Aug 21, 2025
31a2e7f
remove merge conflict
DharshanBJ Aug 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<PackageVersion Include="Microsoft.CSharp" Version="4.5.0" />
<PackageVersion Include="Microsoft.Identity.Client.NativeInterop" Version="$(MSALRuntimeNativeInteropVersion)" IncludeAssets="all" />
<PackageVersion Include="Microsoft.IdentityModel.Abstractions" Version="6.35.0" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.864.35" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2903.40" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.7.250606001" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4188" />
<PackageVersion Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
<!-- Should match Azure Functions runtime: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/4456 -->
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="6.0.1" />
Expand Down
81 changes: 81 additions & 0 deletions LibsAndSamples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Test.Per
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Client.Desktop", "src\client\Microsoft.Identity.Client.Desktop\Microsoft.Identity.Client.Desktop.csproj", "{A7679FF0-19E8-41E3-9F7C-F54235124CC4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Client.Desktop.WinUI3", "src\client\Microsoft.Identity.Client.Desktop.WinUI3\Microsoft.Identity.Client.Desktop.WinUI3.csproj", "{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinUI3PackagedSampleApp", "tests\devapps\WinUI3PackagedSampleApp\WinUI3PackagedSampleApp.csproj", "{B9A98EC5-074E-4366-A475-A246D09C32EE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KerberosConsole", "tests\devapps\KerberosConsole\KerberosConsole.csproj", "{94F35780-220A-4C08-83B9-41168F7017CD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Net5TestApp", "tests\devapps\Net5TestApp\Net5TestApp.csproj", "{998D38B3-344C-4F19-833E-6181B0834AF6}"
Expand Down Expand Up @@ -968,6 +972,81 @@ Global
{A7679FF0-19E8-41E3-9F7C-F54235124CC4}.Release|x64.Build.0 = Release|Any CPU
{A7679FF0-19E8-41E3-9F7C-F54235124CC4}.Release|x86.ActiveCfg = Release|Any CPU
{A7679FF0-19E8-41E3-9F7C-F54235124CC4}.Release|x86.Build.0 = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|Any CPU.ActiveCfg = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|Any CPU.Build.0 = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|ARM.ActiveCfg = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|ARM.Build.0 = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|ARM64.ActiveCfg = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|ARM64.Build.0 = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|iPhone.ActiveCfg = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|iPhone.Build.0 = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|iPhoneSimulator.ActiveCfg = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|iPhoneSimulator.Build.0 = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|x64.ActiveCfg = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|x64.Build.0 = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|x86.ActiveCfg = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug + MobileApps|x86.Build.0 = Debug + MobileApps|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|ARM.ActiveCfg = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|ARM.Build.0 = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|ARM64.Build.0 = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|iPhone.Build.0 = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|x64.ActiveCfg = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|x64.Build.0 = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|x86.ActiveCfg = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Debug|x86.Build.0 = Debug|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|Any CPU.Build.0 = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|ARM.ActiveCfg = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|ARM.Build.0 = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|ARM64.ActiveCfg = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|ARM64.Build.0 = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|iPhone.ActiveCfg = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|iPhone.Build.0 = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|x64.ActiveCfg = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|x64.Build.0 = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|x86.ActiveCfg = Release|Any CPU
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5}.Release|x86.Build.0 = Release|Any CPU
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|Any CPU.ActiveCfg = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|Any CPU.Build.0 = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|ARM.ActiveCfg = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|ARM64.ActiveCfg = Debug|ARM64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|ARM64.Build.0 = Debug|ARM64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|iPhone.ActiveCfg = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|iPhoneSimulator.ActiveCfg = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|x64.ActiveCfg = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|x64.Build.0 = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|x86.ActiveCfg = Debug|x86
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug + MobileApps|x86.Build.0 = Debug|x86
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|Any CPU.ActiveCfg = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|Any CPU.Build.0 = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|ARM.ActiveCfg = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|ARM64.ActiveCfg = Debug|ARM64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|ARM64.Build.0 = Debug|ARM64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|iPhone.ActiveCfg = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|iPhoneSimulator.ActiveCfg = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|x64.ActiveCfg = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|x64.Build.0 = Debug|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|x86.ActiveCfg = Debug|x86
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Debug|x86.Build.0 = Debug|x86
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|Any CPU.ActiveCfg = Release|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|Any CPU.Build.0 = Release|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|ARM.ActiveCfg = Release|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|ARM64.ActiveCfg = Release|ARM64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|ARM64.Build.0 = Release|ARM64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|iPhone.ActiveCfg = Release|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|iPhoneSimulator.ActiveCfg = Release|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|x64.ActiveCfg = Release|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|x64.Build.0 = Release|x64
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|x86.ActiveCfg = Release|x86
{B9A98EC5-074E-4366-A475-A246D09C32EE}.Release|x86.Build.0 = Release|x86
{94F35780-220A-4C08-83B9-41168F7017CD}.Debug + MobileApps|Any CPU.ActiveCfg = Debug + MobileApps|Any CPU
{94F35780-220A-4C08-83B9-41168F7017CD}.Debug + MobileApps|Any CPU.Build.0 = Debug + MobileApps|Any CPU
{94F35780-220A-4C08-83B9-41168F7017CD}.Debug + MobileApps|ARM.ActiveCfg = Debug + MobileApps|Any CPU
Expand Down Expand Up @@ -1936,6 +2015,8 @@ Global
{743BEA88-1903-4AF0-A791-705774F4B99D} = {9B0B5396-4D95-4C15-82ED-DC22B5A3123F}
{F7993CD1-91C1-4E22-9BDA-EAD6D4FB1D36} = {9B0B5396-4D95-4C15-82ED-DC22B5A3123F}
{A7679FF0-19E8-41E3-9F7C-F54235124CC4} = {1A37FD75-94E9-4D6F-953A-0DABBD7B49E9}
{B8689FF1-20F9-4669-CF55-9B2E8B5F8DD5} = {1A37FD75-94E9-4D6F-953A-0DABBD7B49E9}
{B9A98EC5-074E-4366-A475-A246D09C32EE} = {34BE693E-3496-45A4-B1D2-D3A0E068EEDB}
{94F35780-220A-4C08-83B9-41168F7017CD} = {34BE693E-3496-45A4-B1D2-D3A0E068EEDB}
{998D38B3-344C-4F19-833E-6181B0834AF6} = {384BA371-F17F-4A70-9423-D54F71BB3FCB}
{CC07F293-91B9-45A3-AA3A-77885BBCB624} = {34BE693E-3496-45A4-B1D2-D3A0E068EEDB}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>

<PathToMsalSources>$(MSBuildThisFileDirectory)../Microsoft.Identity.Client/</PathToMsalSources>
<PlatformTarget>AnyCPU</PlatformTarget>
<Configurations>Debug;Release;Debug + MobileApps</Configurations>
</PropertyGroup>

<PropertyGroup Label="NuGet and AssemblyInfo metadata">
<!--This should be passed from the VSTS build-->
<MicrosoftIdentityClientVersion Condition="'$(MicrosoftIdentityClientVersion)' == ''">$(MsalInternalVersion)</MicrosoftIdentityClientVersion>
<MicrosoftIdentityClientVersion>$(MicrosoftIdentityClientVersion)</MicrosoftIdentityClientVersion>
<!--This will generate AssemblyVersion, AssemblyFileVersion and AssemblyInformationVersion-->
<Version>$(MicrosoftIdentityClientVersion)</Version>
<!-- Copyright needs to be in the form of © not (c) to be compliant -->
<Title>MSAL.NET extension for WinUI3 desktop applications</Title>
<Description>
This package contains WinUI3-specific binaries for using MSAL.NET with modern Windows applications built on WinUI3 and Windows App SDK.
</Description>
<PackageTags>Microsoft Authentication Library Desktop MSAL WinUI3 Windows App SDK WebView2</PackageTags>
<Product>Microsoft Authentication Library Desktop WinUI3</Product>
</PropertyGroup>

<PropertyGroup Label="For CI build" Condition="'$(TF_BUILD)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<!-- Include shared source files from Desktop project, excluding WebView2WebUi files -->
<ItemGroup>
<Compile Include="..\Microsoft.Identity.Client.Desktop\**\*.cs"
Exclude="..\Microsoft.Identity.Client.Desktop\WebView2WebUi\**\*.cs;..\Microsoft.Identity.Client.Desktop\obj\**\*;..\Microsoft.Identity.Client.Desktop\bin\**\*"
LinkBase="" />

<!-- Include InternalsVisibleTo -->
<Compile Include="..\Microsoft.Identity.Client\Properties\InternalsVisibleTo.cs" Link="Properties\InternalsVisibleTo.cs" />
</ItemGroup>

<!-- WinUI3 and Windows App SDK dependencies -->
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" />
</ItemGroup>

<!-- Project references -->
<ItemGroup>
<ProjectReference Include="..\Microsoft.Identity.Client.Broker\Microsoft.Identity.Client.Broker.csproj" />
<ProjectReference Include="..\Microsoft.Identity.Client\Microsoft.Identity.Client.csproj" />

<PackageReference Remove="Microsoft.CodeAnalysis.PublicApiAnalyzers" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Identity.Client.Http;
using Microsoft.Identity.Client.Internal;
using Microsoft.Identity.Client.Platforms.Features.DesktopOs;
using Microsoft.Identity.Client.UI;
using Microsoft.Identity.Client.Core;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Windowing;
using Windows.Graphics;
using Windows.Graphics.Display;
using Microsoft.UI;
using Microsoft.UI.Dispatching;

namespace Microsoft.Identity.Client.Desktop.WebView2WebUi
{
internal class WebView2WebUi : IWebUI
{
private CoreUIParent _parent;
private RequestContext _requestContext;

public WebView2WebUi(CoreUIParent parent, RequestContext requestContext)
{
_parent = parent;
_requestContext = requestContext;
}

public async Task<AuthorizationResult> AcquireAuthorizationAsync(
Uri authorizationUri,
Uri redirectUri,
RequestContext requestContext,
CancellationToken cancellationToken)
{
AuthorizationResult result = null;

var sendAuthorizeRequest = new Func<Task>(async () =>
{
result = await InvokeEmbeddedWebviewAsync(authorizationUri, redirectUri, cancellationToken).ConfigureAwait(false);
});

if (Thread.CurrentThread.GetApartmentState() == ApartmentState.MTA)
{
if (_parent.SynchronizationContext != null)
{
var tcs = new TaskCompletionSource<AuthorizationResult>();

_parent.SynchronizationContext.Post((state) =>
{
var taskCompletionSource = (TaskCompletionSource<AuthorizationResult>)state;

var asyncOperation = InvokeEmbeddedWebviewAsync(authorizationUri, redirectUri, cancellationToken);

// Handle the completion asynchronously
asyncOperation.ContinueWith(task =>
{
if (task.IsFaulted)
{
var exception = task.Exception?.InnerException ?? task.Exception;
taskCompletionSource.TrySetException(exception);
}
else if (task.IsCanceled)
{
taskCompletionSource.TrySetCanceled();
}
else
{
taskCompletionSource.TrySetResult(task.Result);
}
}, TaskContinuationOptions.ExecuteSynchronously);

}, tcs);

return await tcs.Task.ConfigureAwait(false);
}
else
{
using (var staTaskScheduler = new StaTaskScheduler(1))
{
try
{
Task.Factory.StartNew(
sendAuthorizeRequest,
cancellationToken,
TaskCreationOptions.None,
staTaskScheduler).Wait(cancellationToken);
}
catch (AggregateException ae)
{
requestContext.Logger.ErrorPii(ae.InnerException);
Exception innerException = ae.InnerExceptions[0];

if (innerException is AggregateException exception)
{
innerException = exception.InnerExceptions[0];
}

throw innerException;
}
}
}
}
else
{
await sendAuthorizeRequest().ConfigureAwait(false);
}

return result;
}

public Uri UpdateRedirectUri(Uri redirectUri)
{
RedirectUriHelper.Validate(redirectUri, usesSystemBrowser: false);
return redirectUri;
}

private async Task<AuthorizationResult> InvokeEmbeddedWebviewAsync(Uri startUri, Uri endUri, CancellationToken cancellationToken)
{
var window = new WinUI3WindowWithWebView2(
_parent.OwnerWindow,
_parent?.EmbeddedWebviewOptions,
_requestContext.Logger,
startUri,
endUri);

return await window.DisplayDialogAndInterceptUriAsync(cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Microsoft.Identity.Client.ApiConfig.Parameters;
using Microsoft.Identity.Client.Core;
using Microsoft.Identity.Client.Internal;
using Microsoft.Identity.Client.Platforms.Shared.Desktop.OsBrowser;
using Microsoft.Identity.Client.PlatformsCommon.Shared;
using Microsoft.Identity.Client.UI;
using Microsoft.Web.WebView2.Core;

namespace Microsoft.Identity.Client.Desktop.WebView2WebUi
{
internal class WebView2WebUiFactory : IWebUIFactory
{
private readonly Func<bool> _isWebView2AvailableFunc;

public WebView2WebUiFactory(Func<bool> isWebView2AvailableForTest = null)
{
_isWebView2AvailableFunc = isWebView2AvailableForTest ?? IsWebView2Available;
}

public bool IsSystemWebViewAvailable => IsUserInteractive;

public bool IsUserInteractive => DesktopOsHelper.IsUserInteractive();

public bool IsEmbeddedWebViewAvailable =>
IsUserInteractive &&
IsWebView2Available(); // Look for the globally available WebView2 runtime

public IWebUI CreateAuthenticationDialog(CoreUIParent coreUIParent, WebViewPreference useEmbeddedWebView, RequestContext requestContext)
{
if (useEmbeddedWebView == WebViewPreference.System)
{
requestContext.Logger.Info("Using system browser.");
return new DefaultOsBrowserWebUi(
requestContext.ServiceBundle.PlatformProxy,
requestContext.Logger,
coreUIParent.SystemWebViewOptions);
}

// In NET6+, webview2 is available by default
requestContext.Logger.Info("Using WebView2 embedded browser.");
return new WebView2WebUi(coreUIParent, requestContext);
}

private static bool IsWebView2Available()
{
try
{
string wv2Version = CoreWebView2Environment.GetAvailableBrowserVersionString();
return !string.IsNullOrEmpty(wv2Version);
}
catch (Exception ex) when (ex is BadImageFormatException || ex is DllNotFoundException)
{
throw new MsalClientException(MsalError.WebView2LoaderNotFound, MsalErrorMessage.WebView2LoaderNotFound, ex);
}
}
}
}
Loading
Loading