microsoft / microsoft/microsoft-ui-xaml
Unit tests fail on Azure Pipeline with upgrade to AppSDK 1.8
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
WinUI unit tests do not work on azure build with AppSDK 1.8. Originally my solution was working with 1.7 but the following example uses a New Project > WinUI Unit Test App.
```
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe "@D:\a\_temp\yzzo1rpezuf.tmp"
VSTest version 17.14.0 (x64)
vstest.console.exe "D:\a\1\s\UnitTestApp1\bin\x64\Debug\net8.0-windows10.0.19041.0\win-x64\UnitTestApp1.dll"
/Settings:"D:\a\_temp\vuydbgge32x.tmp.runsettings"
/EnableCodeCoverage
/Logger:"trx"
/TestAdapterPath:"D:\a\1\s"
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
7.0319
Failed TestMethod1 [131 ms]
Error Message:
Unable to create instance of class UnitTestApp1.UnitTest1. Error: System.Runtime.InteropServices.COMException: Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)).
Stack Trace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at WinRT.ActivationFactory.Get(String typeName)
at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions.get__objRef_global__Microsoft_Windows_ApplicationModel_WindowsAppRuntime_DeploymentInitializeOptions()
at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions..ctor()
at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.get_Options() in C:\Users\VssAdministrator\.nuget\packages\microsoft.windowsappsdk.foundation\1.8.251104000\include\DeploymentManagerAutoInitializer.cs:line 44
at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.AccessWindowsAppSDK() in C:\Users\VssAdministrator\.nuget\packages\microsoft.windowsappsdk.foundation\1.8.251104000\include\DeploymentManagerAutoInitializer.cs:line 30
at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Common.AutoInitialize.InitializeWindowsAppSDK() in C:\Users\VssAdministrator\.nuget\packages\microsoft.windowsappsdk.foundation\1.8.251104000\include\WindowsAppRuntimeAutoInitializer.cs:line 22
at .cctor()
Failed TestMethod2
Error Message:
An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute 'Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer.UITestMethodAttribute'.
System.InvalidOperationException: UITestMethodAttribute.DispatcherQueue should not be null. To use UITestMethodAttribute within a WinUI Desktop App, remember to set the static UITestMethodAttribute.DispatcherQueue during the test initialization.
at Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer.UITestMethodAttribute.ExecuteAsync(ITestMethod testMethod) in /_/src/TestFramework/TestFramework.Extensions/Attributes/WinUI_UITestMethodAttribute.cs:line 48
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestMethodRunner.<>c__DisplayClass11_0.<b__0>d.MoveNext() in /_/src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.cs:line 409
--- End of stack trace from previous location ---
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestMethodRunner.ExecuteTestAsync(TestMethodInfo testMethodInfo) in /_/src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.cs:line 418
Results File: D:\a\_temp\TestResults\VssAdministrator_runnervmhqiec_2026-01-02_00_28_07.trx
Attachments:
D:\a\_temp\TestResults\b7ce639f-0707-4562-8385-5bd770977cce\VssAdministrator_runnervmhqiec_2026-01-02.00_28_07.coverage
Total tests: 2
##[error]Test Run Failed.
Failed: 2
Total time: 16.3176 Seconds
Vstest.console.exe exited with code 1.
**************** Completed test execution *********************
Is DonotPublishTestResults enabled false
Test results files: D:\a\_temp\TestResults\VssAdministrator_runnervmhqiec_2026-01-02_00_28_07.trx
Created test run: 1000382
Publishing test results: 2
Publishing test results to test run '1000382'.
TestResults To Publish 2, Test run id:1000382
Test results publishing 2, remaining: 0. Test run id: 1000382
Published test results: 2
Publishing Attachments: 2
Execution Result Code 1 is non zero, checking for failed results
Completed TestExecution Model...
```
### Why is this important?
The developer of the application has to remove the Unit Test step of a build pipeline and cannot rely on Automated CI
### Steps to reproduce the bug
See sample repo https://github.com/alski/TestsFailUnderAppSDK1.8Demo, feel free to reach out for access to azure build
Or..
- Create a new WinUI Unit Test App
- Add Azure pipeline to build and test it
- See build for failures
### Actual behavior
Pipeline build cannot find the test classes
### Expected behavior
I expect the template WinUI Unit Test App to build and pass with Azure pipeline
### Screenshots
Screenshots included in the repro steps
### NuGet package version
WinUI 3 - Windows App SDK 1.8.3: 1.8.251106002
### Windows version
Windows Insider Build (xxxxx)
### Additional context
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the sample repository and the newly created WinUI Unit Test App, then inspect the Azure pipeline step that runs vstest.console.exe against the test assembly. Compare the Windows App SDK 1.8.3 behavior with the reported AppSDK 1.7 setup; done means the template test app builds and both tests pass in Azure Pipelines.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- ci-cd, desktop, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100