Visual Studio App Center - Duplicate 'EmbeddedResource' items were included when building Xamarin Forms app? - xamarin.forms

When building a Xamarin Forms app in Visual Studio App Center it complains about the embedded xaml-files when using netstandard2.0.
Locally with updated Visual Studio and Xamarin Forms it works perfect to build and run.
(CheckForDuplicateItems target) ->
/usr/local/share/dotnet/sdk/2.0.3/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.DefaultItems.targets(276,5):
error : Duplicate 'EmbeddedResource' items were included. The .NET SDK
includes 'EmbeddedResource' items from your project directory by
default. You can either remove these items from your project file, or
set the 'EnableDefaultEmbeddedResourceItems' property to 'false' if
you want to explicitly include them in your project file. For more
information, see https://aka.ms/sdkimplicititems.
How should xaml-files be added to the project if not as embedded?
UPDATE:
The same error is present using VSTS and Hosted Mac Agent

Edit your .csproj file and remove the ItemGroup that contains the EmbeddedResource.
This resolved the issue from me but the original answer came from Xamarin Forums

Related

Xamarin.Forms upgraded to Maui - Visual Studio Cannot debug/run?

Application upgraded using Microsoft's auto upgrade command line tool.
Some code fixes, and the code builds successfully.
Visual Studio however does not show me any way to debug my app.
When trying to click on Debug anyway, a random Android Emulator from my list(which is not showing currently)
Will open, but deployment will fail without specifying the reason.
Has anyone managed to upgrade an existing Xamarin.Forms project to Maui?
I managed to make VS recognize the Android project in my converted solution.
I added the <SingleProject>true</SingleProject> property into my Android project's .csproj file under the first/main property group, closed VS, deleted Bin, Obj, .vs folders.
After starting VS again , I rebuilt and VS allowed me to debug on selected .net targets like a single project Maui solution.
This is very strange that it works, since this solution is made of 3 project like in a Xamarin.Forms solution, so it doesn't make since that adding this property solves the issue, but there you go.
Delete .bin and .obj folders. Delete solution's hidden .vs folder. Build. Does it show debug option now?
Try restarting VS (after the successful build). Now work?
If not, Create a new project using Maui template.
Use solution / manage all nugets to add nugets used by your project.
Copy all your source files into that new project.
Project / "Add existing items": all those source files.

Xamarin.Android Build Error for Xamarin Forms 4 Solution

I am trying to compile a newly created Xamarin.Forms solution using Visual Studio Pro 2019 version 16.1.3. I use the stable Xamarin.Forms version 4.0.0.425677. The solution contains an iOS, Android and UWP project.
When I try to compile I get the following Android compilation error even without having made any code changes.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(3326,2): error : A part of the path "AccessibilityManagerCompat_AccessibilityStateChangeListenerImplementor.class" could not be found
The only related post I found was here which recommends to delete bin and obj folders in the Android project. This does not apply since I start with an new solution in the first place. Any ideas what the cause could be?
Well, it turns out that I only get this issue when I have the term "Xamarin" in my Android project name. This seems to confuse the Android compiler.

Xamarin forms android: Could not determine API level for $(TargetFrameworkVersion) of 'v8.1'

Getting following error when rebuilding xamarin forms android project.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error XA0000: Could not determine API level for $(TargetFrameworkVersion) of 'v8.1'. (XA0000) (Myproject.Android)
Found the same issue in some other threads. The solution on there is open .csproj file and change AndroidUseLatestPlatformSdk from True to False, and rebuild. I found this solution on here and here.
But I don't know which .csproj file need to modify? Can some one tell it more clearly?
You'll want to edit Myproject.Android.csproj.
Here's how to edit a csproj in Visual Studio:
Visual Studio for Mac
Visual Studio on PC
1. Unload the Project
2. Edit the File
3. Reload the Project
Just go to options and then general
then select appropriate target version

An IOS Application project must reference the project containing this xaml file in order to render in the previewer

In Previewer below error is shown An IOS Application project must reference the project containing this xaml file in order to render in the previewer.
PCL reference is added in IOS project and Xamarin.forms latest nuget package is also added .
The solution is simple. This works for me in android project. The error message is self explanatory. Solution: Check your android project and make sure the dll of your PCL/.net standard project is reference. In my own case, its referenced but shows a yellow color. I deleted the reference and re-reference by right clicking on the android project=>projects=>solution=>select the PCL/.net standard project => ok ..

Xamarin Forms Item Templates Missing in Visual Studio

I had to restore my Windows to a previous restore point and then Xamarin stopped working. I ended up uninstalling Xamarin and Visual Studio 2015 to get Xamarin working again, which it mostly is. I cannot update Xamarin Forms to the latest stable 2.3.3.180 but 2.3.3.175 is working for now.
The most troublesome issue is when I right click my PCL project and select Add->New Item, in the list of Installed templates there is no Cross-Platform folder and nowhere to select "Forms Xaml Page" item. How can I get these templates installed? Have done reinstall and repair on both VS and Xamarin and I can't get these templates to show up.
Thanks,
Tony
See my post here:
https://stackoverflow.com/a/42341624/2274377
C:\Program Files (x86)\Microsoft Visual Studio14.0\Common7\IDE\Extensions\
Find the correct subfolder. This can be tricky. I had a Xamarin folder, but that was not the right one. In my case it was folder
wa13kl1p.m3s. However, open your folders and check it there is some
Xamarin.Forms.Templates... files in it.
Inside that folder navigate to the T/P/CSharp folder.
Copy the Cross-Platform folder over to C:\Users\Documents\Visual Studio
2015\Templates\ProjectTemplates\Visual C#
Same thing for the ItemTemplates:
But this time navigate to T/I/CSharp folder.
Copy the Cross-Platform folder over to C:\Users\Documents\Visual Studio2015\Templates\ItemTemplates\Visual C#

Resources