Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error publishing .NET MAUI project: the target "_GenerateAppxPackage" does not exist

I have a .NET MAUI project that was created with VS2022 Preview 2, and it builds without errors or warnings and works as expected in the debugger. Prior to updating Visual Studio to Version 17.4.0 Preview 4.0 I was able to publish the project as a sideloadable MSIX from within VS.

Since updating, I get the following error when I click Create in the Create App Packages wizard:

MSB4057 The target "_GenerateAppxPackage" does not exist in the project.

The error is listed against the MAUI project's .csproj file.

I've tried creating a separate new, default MAUI project in the new preview - this publishes ok and (as far as I can see) doesn't contain _GenerateAppxPackage anywhere within its files or project structure. So for now I'm assuming this isn't something new that was added with the preview.

I found some references to _GenerateAppxPackage on the web but they appear to refer to Azure integration. My project is a stand-alone data transformation app that doesn't even access the net.

I'm at a loss what to try next. I don't know what this target refers to, where it should "exist" within the project, or what it does. Can anyone help me understand the problem and/or point me to a solution?

Update: 2022-10-28:

  • I tried deleting the project structure and creating it from scratch with File -> New Project, then adding back only the .cs and .xaml files. Publishing the recreated project gives me the same error.

  • I also tried uninstalling the VS preview and re-downloading and installing it. Again, publishing the project gives me the same error.

I still have no idea what is causing this, or even where to start looking.

like image 367
Andy Johnson Avatar asked Dec 07 '25 12:12

Andy Johnson


2 Answers

I faced with the same problem at Visual Studio 2022 17.4.0 (net6.0-windows10.0.19041.0).

The simplest solution for me was be using the command dotnet publish directly.

At root of project just write in terminal:

dotnet publish -f net6.0-windows10.0.19041.0  -c /p:RuntimeIdentifierOverride=win10-x64
like image 158
Alykoff Gali Avatar answered Dec 11 '25 15:12

Alykoff Gali


For me this only occurs when "Target the Android Platform" is unchecked. Its a VS flaw that i reported to Microsoft. It makes the publishing profile unusable. If i need to create a .MSIX i have to temporarily check Target Android.

like image 23
Kevin Avatar answered Dec 11 '25 15:12

Kevin