14

Using VS 2017 15.4.0

Following James Montemagno "Upgrading to Xamarin.Forms to .NET Standard"

https://channel9.msdn.com/Shows/XamarinShow/Snack-Pack-15-Upgrading-to-XamarinForms-to-NET-Standard?ocid=player

When trying to Clean/Build I am receiving the error:

Severity Code Description Project File Line Suppression State 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. The duplicate items were: 'App.xaml'; 'MainPage.xaml' App5.core C:\Program Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets 274

Any solution please?

AG70
  • 874
  • 1
  • 9
  • 23

8 Answers8

15

Found the solution... Right click on the new .NET Standard project I have created "App5" and choose Edit App5.csproj I have deleted this code from the file and the error gone.

      <ItemGroup>
  <EmbeddedResource Include="App.xaml">
    <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
  </EmbeddedResource>
  <EmbeddedResource Include="MainPage.xaml">
    <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
  </EmbeddedResource>
</ItemGroup>
AG70
  • 874
  • 1
  • 9
  • 23
  • This worked, but I wonder why. How can the project find the items when they are not listed in the project file at all? – Martin Braun Nov 01 '17 at 22:55
  • 1
    It basically includes all the items inside the directory unless mentioned to exclude the specific item. – zafar Jan 18 '18 at 15:05
11

I found various suggestions, but this answer was easily the best for me, both in simplicity and elegance:

  • In Solution Explorer, enable "Show All Files". This displays all files in each folder, including those excluded from the project.

For each item listed in the error message:

  • Exclude from project
  • Include in project

Then

  • In Solution Explorer, disable "Show All Files".
riemannzz
  • 1,731
  • 1
  • 13
  • 8
8

My mistake was that I added embedded resource while simulator with app was running.

Soo... I had THIS added automatically inside .csproj file:

<EmbeddedResource Include="**/*" />

Remove it, and then everything should be fine

idchlife
  • 554
  • 1
  • 6
  • 16
6

According to bugzilla of xamarin at some point you were required to insert to make it work with the new csproj format.

 <ItemGroup>
    <!-- https://bugzilla.xamarin.com/show_bug.cgi?id=55591 -->
    <None Remove="**\*.xaml" />

    <Compile Update="**\*.xaml.cs" DependentUpon="%(Filename)" />
    <EmbeddedResource Include="**\*.xaml" SubType="Designer" Generator="MSBuild:UpdateDesignTimeXaml" />
  </ItemGroup>

Source

I would imagine that xamarin decided to add that to the default build targets now.

So to fix it you have to do the following:

  • Open your shared .csproj file.

  • Remove all Itemgroups related to adding xaml pages and *.cs

  • clean + rebuild.

Dbl
  • 5,634
  • 3
  • 41
  • 66
3

It happened to me in MS Visual Studio for Mac after I have added two font files as embedded resources.

These files were titled with the same prefix (Lora-Regular.ttf & Lora-Bold.ttf) and it looks like my IDE did handle this in a bad way.

Indeed, the following weird line was inserted in my .csproj file :

<EmbeddedResource Include="**/*" />

All I did was removing this line and error disapeared.

Kapusch
  • 287
  • 1
  • 13
0

Try to clean it manually with these steps:

  • Close your VS
  • remove bin and obj folders from iOS, Android and the Common (Your project name) folder.
  • remove all content from the packages folder
  • open a terminal, navigate to your projects folder and type nuget locals all -clear
  • then type nuget restore

and finally open VS again and let me know if the problem still exists

Tomislav Erić
  • 215
  • 1
  • 8
0

For me issue was in one file name. I used underscore (_) in the filename. I was working with file name AppResource.zh_cn.resx. May be it could help someone.

Inshal Irshad
  • 227
  • 3
  • 17
0

for me unloading and reloading project again worked!

Asım Gündüz
  • 1,257
  • 3
  • 17
  • 42