I have created a WinUI3 application that uses the Microsoft.Web.WebView2 package (version 1.0.2045.28). When I build or publish the app locally from Visual Studio the app works as expected. When I publish it from an Azure DevOps pipeline however, I only get a blank white page whenever I launch the WebView from within the app.
I have determined that the problem is likely caused by the Microsoft.Web.WebView2.Core.dll file in my app directory being a 32 bit DLL instead of 64 bit when publishing the app via the DevOps pipeline, despite the fact that I have set X64 as the target platform. (Swapping it out afterwards solves the problem).
How can I make sure the DevOps pipeline builds the app with the 64 bit version of WebView2?
Here's the relevant parts from my pipeline:
pool:
vmImage: 'windows-latest'
variables:
solution: 'MySolution/MySolution.sln'
project: 'MySolution/MyApp/MyApp.csproj'
buildPlatform: 'X64'
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false
projects: '$(project)'
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory) -p:Platform=$(buildPlatform) -p:PublishSingleFile=false --self-contained true'
zipAfterPublish: true
modifyOutputPath: false
I also tried to add -r win-x64 to the arguments but it made no difference.
I've found a workaround. The root of the problem seems to be that becuase I'm referencing both Microsoft.Identity.Client (which has WebView2 as a dependency) and Microsoft.Web.WebView2, there is a conflict between the packages: https://github.com/microsoft/microsoft-ui-xaml/issues/5689
To workaround the issue above I have the following lines in my .csproj file, otherwise it won't compile:
...the DLL that ends up in my output folder seems to be a 32 bit version built for .Net core 3.1, probably from the webview2 dependency for Microsoft.Identity.Client.
I discovered that the correct version of the DLL can be found in the obj folder after a build, so I managed to add theese lines to my .csproj file to copy it to the output directory after a build or publish:
Not a solution to the actual problem, but with this workaround my app now works as expected.