Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am getting 'A project cannot have mor than one AplicationXaml item'

Tags:

c#

uwp-xaml

I have a UWP project and when i try to build it for ARM it builds fine, however, when I build it for x86 or x64 I am getting 'A project cannot have more than one ApplicationXaml item'. I have tried to clean the solution and rebuild again but the error couldn't go away. I have also tried to change the build action and rebuild again but no luck so far. Any idea? I am using Visual Studio Enterprise 2017.

like image 796
Mike Avatar asked Dec 10 '18 01:12

Mike


2 Answers

This is a Visual Studio 2017 bug, which was also reported to Microsoft and which I also suffer from time to time.

There are some steps to "fix" it:

  1. Clean Solution every time before running the app
  2. Remove ApplicationDefinition

enter image description here

and add it back.

  1. edit the UWP.csproj (remove some part, save proj and ignore reload, now add the removed part back, save and reload project).

Now try to run the app.

like image 61
magicandre1981 Avatar answered Oct 11 '22 02:10

magicandre1981


This is summary of possible solutions as posted on the Microsoft and Git pages for this issue as well as on this SO page. Some solutions are faster/simpler than others so I have ordered possible solutions from the easiest to the more involved fixes and included some more detailed instructions for folks that are new to VS.

According to the git page for this issue it was confirmed by Microsoft staff to be a VS bug. It's been around for about 3 years and as of 2020 has unfortunately STILL not been fixed.

Possible solutions:

  1. Clean. You can do this by project or solution, or both. To clean project: right-click on project >clean. To clean solution select Build >clean solution or right-click on solution >clean solution. Now try to build your solution again. It's also not a bad idea to clean each time you try a potential solution listed below.
  2. Unload & reload the project. You can do this by right-clicking on the project and selecting unload project... give it a moment then right-click and select reload project.
  3. Rebuild the solution (as opposed to build).
  4. Check your App.xaml definitions. If you have a cross-platform solution your main project/shared code project has an App.xaml file. Open the properties for this file (right-click >properties). The build action should be set to embedded resource.
    embedded resource
    Your UWP app will also have an App.xaml file. The build action for your UWP's App.xaml should be set to application definition.
    application definition
  5. If these are already correct, remove the definitions (set build action to none) then set them back to the correct settings again.

  6. Edit the UWP.csproj (remove some part, save proj and ignore reload, now add the removed part back, save and reload project).

like image 29
SendETHToThisAddress Avatar answered Oct 11 '22 00:10

SendETHToThisAddress