Bug 55591 - XF .xaml files in .NETStandard library appear twice in solution explorer
Summary: XF .xaml files in .NETStandard library appear twice in solution explorer
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: .NET Core support ()
Version: 7.0 (VSforMac)
Hardware: PC Mac OS
: High normal
Target Milestone: 15.2
Assignee: Matt Ward
Depends on:
Reported: 2017-04-25 20:28 UTC by Kyle White
Modified: 2017-04-26 21:14 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Kyle White 2017-04-25 20:28:36 UTC
Screenshot: https://www.screencast.com/t/2syICEk9H8bx

This project: https://github.com/onovotny/SampleXamFormsWithNetStandard - reproduces it 100% of the time for me.

About info: https://gist.github.com/kdubau/401a4a42bd922ca4ee12d9adbab9a510
Comment 1 Kyle White 2017-04-25 20:34:39 UTC
The portable project is also new msbuild "sdk style" format, maybe that's it
Comment 2 Matt Ward 2017-04-26 08:47:02 UTC
The reason there are two files here is that the .NET Core sdk MSBuild imports have a wildcard include for all files that are not C# files:

    <None Include="**/*" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />

So the .xaml file is included as a None item by default. The project then has an EmbeddedResource Include which adds the .xaml file again.

    <EmbeddedResource Include="MainPage.xaml" SubType="Designer" Generator="MSBuild:UpdateDesignTimeXaml" />

So the file is added twice in the project. If you remove the EmbeddedResource project item from the .csproj and re-open the project you can still see the .xaml files included as None items.

The project file I suspect has been edited by hand. In Visual Studio for Windows the Solution Explorer does not show duplicate project items, even though they may exist, whereas Visual Studio for Mac does show them.

If you add a .xaml file using the IDE (Visual Studio for Mac or Visual Studio 2017 on Windows), and then change its Build Action to be EmbeddedResource you will that the .xaml file is excluded from the None items so it is not added as a duplicate:

    <None Remove="MainPage.xaml" />
    <EmbeddedResource Include="MainPage.xaml" />
Comment 3 Kyle White 2017-04-26 12:08:23 UTC
Should we consider making VSMac more like VSWin and hide the duplicates?
Comment 4 Matt Ward 2017-04-26 12:12:49 UTC
There are pros and cons either way. VS on Windows is hiding a potential bug in the project. VS on Mac shows you there is a problem.
Comment 5 Oren Novotny 2017-04-26 21:14:38 UTC
I think it's unfortunate that this is required in VSfM. There should be no harm in having "None" items in the tree. Perhaps there should be duplicates for other items, like if you have something as Content and Compile, that should be weird. But None should be combinable with everything else,

There's other reasons too -- like I have a global None include to get the solution explorer to show files that are really only conditionally included

Look here for an example:

The files in \Platform are included via None so that they show up in the solution explorer.

Then later, they're conditionally included as a Compile, Resource, etc. I shouldn't have to Remove the None.