Using Visual Studio 2022 Enterprise 64-bit v17.4.2 on Windows 10 v22H2 64-bit
Repro steps.
- Create a new project, ".NET MAUI App", with the default .NET 6.0 selected as part of the new project wizard
- Click the run button from the toolbar to build and run the app on Windows in the debugger
- Should work fine
- Edit the Windows app manifest (Platforms\Windows\Package.appxmanifest) in a text editor
- Note that, although we haven't checked any capabilities in the UI editor for this file, it still adds a capability. Towards the end of the file, see the Capabilities elements and within that, see that it has added the runFullTrust capability
- Remove the capability, save, and attempt to run again
- This time it will fail to build
- Re-adding the capability to the manifest file resolves the problem and it runs again
So it appears the .NET MAUI app needs to have this capability set. I'm curious why that is. The question came up for me when attempting to submit a very simple app (just a UI with some buttons and text display) to the Microsoft Store. Due to the presence of this capability, I had to provide an explanation, during app submission, why I needed the capability. I have no idea, but it seems something about MAUI may need it? Does anyone know why this is needed?
----------
The section in the app manifest to look for is below.
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
----------
From the build output....
0>C:\Users\david\.nuget\packages\microsoft.windowsappsdk\1.1.3\buildTransitive\Microsoft.Build.Msix.Packaging.targets(901,5): Error APPX0002: Task 'WinAppSdkGenerateAppxManifest' failed. Object reference not set to an instance of an object.
Then the below is repeated a number of times
0>C:\Users\david\.nuget\packages\microsoft.windowsappsdk\1.1.3\buildTransitive\Microsoft.Build.Msix.Packaging.targets(901,5): Error MSB4018: The "WinAppSdkGenerateAppxManifest" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at Microsoft.VisualStudio.Telemetry.MachinePropertyBag.ParseIn(String filepath)
at Microsoft.VisualStudio.Telemetry.MachinePropertyBag.LoadStore()
at Microsoft.VisualStudio.Telemetry.WindowsIdentityInformationProvider.<>c.<.cctor>b__12_0()
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at Microsoft.VisualStudio.Telemetry.IdentityInformationProvider.SchedulePostPersistedSharedPropertyAndSendAnyFaults(TelemetrySession telemetrySession, ITelemetryScheduler scheduler)
at Microsoft.VisualStudio.Telemetry.TelemetrySession.InitializeSession()
at Microsoft.VisualStudio.Telemetry.TelemetrySession.HardwareIdCalculationCompleted(Object sender, EventArgs e)
at Microsoft.VisualStudio.Telemetry.TelemetrySession.DisposeStart()
at Microsoft.VisualStudio.Telemetry.TelemetrySession.DisposeManagedResources()
at Microsoft.VisualStudio.Telemetry.TelemetryDisposableObject.Dispose()
at Microsoft.Build.Msix.AppxPackagingTaskHelper.PostTelemetryFault(Exception e)
at Microsoft.Build.Msix.AppxPackagingTaskHelper.Execute(String file)
at Microsoft.Build.Msix.AppxManifest.WinAppSdkGenerateAppxManifest.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].