Reputation: 391
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.
Upvotes: 12
Views: 5142
Reputation: 3714
This is a 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 years and as of 2021 has unfortunately STILL not been fixed.
Possible solutions:
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.
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.
Rebuild the solution (as opposed to build).
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.
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.
If these are already correct, remove the definitions (set build action to none) then set them back to the correct settings again.
Edit the UWP.csproj (remove some part, save proj and ignore reload, now add the removed part back, save and reload project).
Upvotes: 4
Reputation: 28826
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:
ApplicationDefinition
and add it back.
Now try to run the app.
Upvotes: 7
Reputation: 14649
The error is caused by that you have multiple Application XAML item.
To fix this issue you can search the project with the keyword 'Application' and delete the duplicate XAML item. And if the code behind class(Application) is also duplicate, you can also delete it.
Upvotes: 1