How can I deploy an Unpackaged, Self Contained, C++ WindowsAppSDK App from an MSI Installer?

PeterCtrl 41 Reputation points
2023-11-15T10:20:27.37+00:00

I want to provide an installable WindowsAppSDK application which is entirely self contained and unpackaged. We provide a client with an installer and the prerequisites, WindowsAppSdk runtime and everything else necessary is installed/shipped and it just works.

I took the unpackaged C++ console sample from here https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/Unpackaged/cpp-console-unpackaged and built an MSI using free version of Advanced Installer (there's a bug in the Microsoft Visual Studio Installer Projects 2022 extension**)**. This worked on my local machine. When I moved the MSI to a Windows 10 machine, I had to manually install the VC++ Redistributables but it subsequently worked.

The next step was taking this sample https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/SelfContainedDeployment/cpp/cpp-winui-unpackaged. Building this is into an MSI succeeds but deploying, even to my own machine, is consistently unsuccessful. There are no errors thrown, the exe just doesn't start. The windows event viewer shows an application crash with these details:

Faulting application name: SelfContainedDeployment.exe, version: 0.0.0.0, time stamp: 0x65537f0e

Faulting module name: Microsoft.UI.Xaml.dll, version: 3.1.4.0, time stamp: 0x88757e1c

Exception code: 0xc000027b

Fault offset: 0x00000000003b6ee4

Faulting process ID: 0x0x54C8

Faulting application start time: 0x0x1DA17080FC374D0

Faulting application path: C:\Program Files\SelfContained\SelfContainedDeployment.exe

Faulting module path: C:\Program Files\SelfContained\Microsoft.UI.Xaml.dll

Report ID: 71f6355c-8eaa-4f44-b3c9-985a813658ce

Faulting package full name:

Faulting package-relative application ID:

The vcxproj has the correct properties assigned:

<AppContainerApplication>false</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>  <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>     <WindowsTargetPlatformMinVersion>10.0.22000.0</WindowsTargetPlatformMinVersion>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<AppxPackage>false</AppxPackage>
<WindowsPackageType>None</WindowsPackageType>

I haven't changed anything within this sample so it should be configured properly. As the code runs from VS on my machine and from the build folder inside the project, there can't be anything missing.

Please advise on how this can be done.

Windows development | Windows App SDK
Developer technologies | C++
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 12,731 Reputation points Microsoft External Staff
    2023-11-16T08:12:20.4266667+00:00

    If I copy the whole folder to the desktop for example, then it works.

    That means the Self-contained build is fine. I also make it work.

    The installer packager should be doing this for me but then the above issue arises.

    But have you compared the files extracted from the MSI and the copied files?

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. PeterCtrl 41 Reputation points
    2023-11-16T10:11:20.71+00:00

    Make sure that your installer is copying absolutely everything! At first glance it was only the asset files that were missing but this wasn't the case you also need "resources.pri".

    There are some unnecessary language assets but I've included en-GB and en-us alongside the Assets folder and resources.pri.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.