I have three WPF applications that I am including in a MSIX package. I have a solution that contains the three applications along with shared projects and a "Windows Application Packaging Project". I can build the MSIX by Choosing Publish -> Create App Packages on the Packaging project in Visual Studio. I am choosing Sideloading with a self-signed certificate and a Release (Any CPU) option.

This produces the MSIX output as expected.
I'm now trying to do the same thing through MSBuild so that I can integrate this into our automated build system. I'm using the command:
MSBuild.exe /restore /p:AppxBundle=Never /p:UapAppxPackageBuildMode=Sideloading /p:Configuration=Release;Platform="Any CPU" /p:AppxPackageDir=C:\temp\Output\ /p:AppxPackageSigningEnabled=false
This produces errors for the WPF applications as per below.
:\Repos\app\app.sln" (default target) (1:2) ->
"C:\Repos\app\appPackage\appPackage.wapproj" (default target) (19:6) ->
"C:\Repos\app\app\app.csproj" (publish target) (2:18) ->
C:\Program Files\dotnet\sdk\6.0.107\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file 'C:\Repos\app\app\obj\project.assets.json' doesn't have a target for 'net6.0-windows10.0.19041/win-x86'. Ensure that restore has run and that you have included 'net6.0-windows10.0.19041' in the TargetFrameworks for your project. You may also need to include 'win-x86' in your project's RuntimeIdentifiers. [C:\Repos\app\app\app.csproj]
Why does this work in Visual Studio, but no in MSBuild? And how can I get this to work in MSBuild?