Friday, July 1, 2022

Build pipeline for a Desktop Bridged Xamarin project

By the way, I am writing this with Open Live Writer, which finally back again supports Blogger. Not officially though…

Let us start the story of the title.

An explanation for the cryptic title first.

What is Desktop Bridge? As explained here, its goal is to create a bridge between the new development approach introduced in Windows 10 (the Universal Windows Platform) and the traditional desktop application. 

In my case however, I came across this idea when I was seeking if feasible to use the systray from my Xamarin/UWP application. I want to make my app like MS Teams, which runs when you starts your PC, stays up in the systray, showing the status (your availability as it is seen by others). I found this blog post. Its sample code is found as a part of the Microsoft GitHub repo for Desktop Bridge samples. It explains how to enable a UWP package to have executables that run as full trust instead of in an app container. 

How to have an UWP app start at sign-in is found here.

I brought these ideas into my Xamarin project, have had it acts like Teams as described above. Very happy.

The next step is to establish its build process as a Azure Pipeline, so my business colleagues come directly there to find the app and test for each feature request, bug fix etc.

I am using a Cloud agent. At the beginning, it fails in building the systray component project. The project has a reference to c:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0\Windows.winmd, which is not found on the cloud agent machine.

##[warning]C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2302,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Windows". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

Interestingly though, it appears to me that it is not that the file (part of Windows SDK if I am not wrong) does not exist on the machine, but the reference is somewhat modified…

For SearchPath "{HintPathFromItem}".
Considered "D:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0\Windows.winmd", but it didn't exist.

It is C not D, the original reference.

I struggled, and finally seems to have found a bit odd but nevertheless working solution, which is to copy the file (it does exist!) to the project’s bin folder so it is found.

Other may-be-oneday-useful info:

Tha’s it!