Open
Description
Describe the bug
Creating a new project with from template in Visual Studio and publishing them to msixbundle only produces crashing output but nothing working
Steps to reproduce the bug
- Open Visual Studio and create a new project
- Select blank app with windows application packaging project (WinUI 3 in Desktop)
- Give it a name and create it (target and minimum version seem not really to matter)
- Run it (it will run properly)
- Right-click the packaging project -> Publish -> Create App Packages ... -> Sideloading -> Select a vertificate -> Create!
- it will fail "The specified RuntimeIdentifier is not recognized" -> okay by removing all win10-xxx runtime identifiers and only keeping the win-xxx identifiers this will work.
- Jump to the output folder and install the msixbundle.
- Try to launch the app from the start menu -> Nothing will happen
- Check the system event log. There is an error containing a hint to C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.5_5001.178.1908.0_x64__8wekyb3d8bbwe\Microsoft.ui.xaml.dll#
- By setting PublishTrimmed to false and PublishReadyToRun to True in the publish profile as well as WindowsAppSDKSelfContained to True in the csproj and wapproj this can be solved
- Publish again and install it: Now it will crash again:
Application: App.exe
CoreCLR Version: 8.0.724.31311
.NET Version: 8.0.7
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException: The type initializer for '<Module>' threw an exception.
---> System.MissingMethodException: Method not found: 'Void System.Environment.SetEnvironmentVariable(System.String, System.String)'.
at Microsoft.Windows.Foundation.UndockedRegFreeWinRTCS.AutoInitialize.AccessWindowsAppSDK()
--- End of inner exception stack trace ---
Expected behavior
Creating an app package should produce something that contains all necessary references will start without a crash, or there should be at least a guide somewhere how to get it running
Screenshots
No response
NuGet package version
Windows App SDK 1.5.5: 1.5.240627000
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 22H2 (22621, 2022 Update)
IDE
Visual Studio 2022
Additional context
No response