Friday, January 3, 2020

UWP app 101

- Error when adding a xUnit Test project
Error NU1201 Project FileUploaderAdal is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Project FileUploaderAdal supports: uap10.0.17763 (UAP,Version=v10.0.17763) FileUploaderAdal.xUnitTests C:\dev\testdevops\FileUploaderAdal\FileUploaderAdal.xUnitTests\FileUploaderAdal.xUnitTests.csproj

.NET Core app cannot add a reference to UWP app and vice versa.

Soluiton: Create one project with .NET Standard and put classes you want to test, which UWP and xUnit .NET Core both can access.



- xUnit Test does not generate code coverage
Install coverlet.msbuild Nuget package

- Unable to authenticate with Azure Active Directory
When: Interactive login (AcquireTokenInteractive) after entering your username
Error message: We can't connect to the service you need right now. Check your network connection or retry this again later.



Solution: Add some capabilities to Package.appxmanifest

- Error
Error: When is Image file binding at .xaml file, like Image Source="{x:Bind Image}" is null, compile error happens

- Run error
{"Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=5.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"Microsoft.IdentityModel.Clients.ActiveDirectory, Version=5.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}

Solution:  This happens when nuget package versions are not same across all projects in the solution

- AcquireTokenAsync does not work at ADAL .NET Stadard
Solution 1: Use MSAL
Solution 2: Use AcquireTokenAsync ADAL at UWP app

- MSAL ConfidentialClientApplicationBuilder
MSAL is a multi-framework library. All Confidential Client flows, including the one presented here, are available on: .NET Core, .NET Desktop .NET Standard. They are not available on the mobile platforms (UWP, Xamarin.iOS, and Xamarin.Android) as these only support public client applications which don't know how to prove the application's identity to the Identity Provider. This secure connection can be achieved on web app or web API back-ends by deploying a certificate.
Supported platforms to build a daemon application are .NET Framework and .NET Core platforms (not UWP, Xamarin.iOS, and Xamarin.Android as those platforms are used to build public client applications)
https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-daemon-app-configuration?tabs=dotnet




No comments:

Post a Comment