Skip to content

Add support for testing unpackaged WinUI applications #2784

Closed

Description

Results of my investigations on the WinUI issue #1127 (comment) are showing that we now work correctly for all cases but unpackaged applications. Although, this is not a work related to MSTest, I want to keep track of this missing feature.

AB#2050311

Activity

  1. michael-hawker commented on Apr 30, 2024

    @michael-hawker

    Thanks Amaury Levé (@Evangelink), is there an issue tracking this in the WinAppSDK repo we can link to?

    Also, copying your matrix here and formatting as a table:

    WindowsAppSDKSelfContained Not set True False
    WindowsPackageType Not set None MSIX Not set None MSIX Not set None MSIX
    Result with VSTest ✅ ❌ ✅ ✅ ❌ ✅ ✅ ❌ ✅

    And the resulting error for the None WindowsPackageType:

    File name: 'C:\src\temp\MSTestWinUI\UnitTest\bin\x64\Debug\net6.0-windows10.0.19041.0\win10-x64\AppxManifest.xml'
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
       at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
       at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
       at System.Xml.XmlTextReaderImpl.FinishInitUriString()
       at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
       at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
       at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.AppxManifestFile.ReadTargetPlatformVersions()
       at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.AppxManifestFile.get_TargetPlatformVersion()
       at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.Deployer.Microsoft.VisualStudio.UwpTestHostRuntimeProvider.IDeployer.get_TargetPlatformVersion()
       at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.UwpTestHostManager.<LaunchHostAsync>d__36.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.UwpTestHostManager.<Microsoft-VisualStudio-TestPlatform-ObjectModel-Host-ITestRuntimeProvider-LaunchTestHostAsync>d__28.MoveNext()<---
    
  2. Evangelink commented on May 2, 2024

    @Evangelink
    MemberAuthor

    Thanks Amaury Levé (@Evangelink), is there an issue tracking this in the WinAppSDK repo we can link to?

    Not yet. I am still discussing some details but I will post here the ticket or info once it's sorted.

  3. testplatform-bot commented on May 2, 2024

    @testplatform-bot
    Contributor

    ✅ Successfully linked to Azure Boards work item(s):

  4. Evangelink commented on Jun 25, 2024

    @Evangelink
    MemberAuthor

    Postponing to next iteration as there were many bug fixes to handle this sprint.

  5. 8 remaining items

  6. ghord commented on Jan 26, 2025

    @ghord

    Please consider running tests as unpackaged. It is really weird to require package manifest with empty logo/images for winui3 unit test projects.

  7. abdes commented on Oct 8, 2025

    @abdes

    Please fix it. It's crazy that we are currently using workarounds that bypass UITest and can perfectly run UI tests with WinUI unpackaged, inside visual studio, but the Microsoft team is dismissing this scenario for months...

    Is WinUI that badly perceived at Microsoft?

  8. Evangelink commented on Jul 30, 2026

    @Evangelink
    MemberAuthor

    Closing this: unpackaged WinUI apps can now be tested, via Microsoft.Testing.Platform. Shipped in #10330.

    What works now

    Set WindowsPackageType=None and EnableMSTestRunner=true and the app is its own test host, so nothing needs to deploy or activate it:

    <UseWinUI>true</UseWinUI>
    <WindowsPackageType>None</WindowsPackageType>
    <EnableMSTestRunner>true</EnableMSTestRunner>
    <GenerateTestingPlatformEntryPoint>false</GenerateTestingPlatformEntryPoint>

    Two things were fixed along the way rather than just documented:

    • [UITestMethod] used to swallow startup failures, leaving the completion source uncompleted so the whole run hung with no diagnostic. A throwing Application constructor, or an unresolvable Windows App SDK runtime in an unpackaged app (REGDB_E_CLASSNOTREG), now fails the test with the real cause.
    • Microsoft.Testing.Extensions.PackagedApp used to enable its launcher on any Windows run, which forced the test-host-controller model and a full copy of the build output to a deployment directory. It is now layout-aware, so an unpackaged app that references it (often transitively through a shared Directory.Packages.props) pays nothing for it.

    What is still not supported, and why

    VSTest. That is the configuration this issue's matrix measured, and it is unchanged: VSTest routes every UseWinUI project through its UwpTestHostRuntimeProvider, which unconditionally reads AppxManifest.xml from the build output and throws the FileNotFoundException above when there is none. That provider ships in Visual Studio, not in this repository, so it cannot be fixed here.

    That matches how the issue was originally framed ("this is not a work related to MSTest, I want to keep track of this missing feature"). The tracked capability now exists, and the remaining gap is a VSTest limitation with a supported alternative, so there is nothing further to track here. If you hit the AppxManifest.xml error, switching that project to EnableMSTestRunner=true is the fix.

  9. abdes commented on Jul 30, 2026

    @abdes

    Thank you.

  10. Evangelink commented on Jul 30, 2026

    @Evangelink
    MemberAuthor

    Abdessattar Sassi (@abdes) if you get a chance to test it out and give me feedback, that'd be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions