Bug 58897 - Cannot Compile Netstandard Library with 2.4.0-pre1
Summary: Cannot Compile Netstandard Library with 2.4.0-pre1
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.4.0
Hardware: PC Windows
: High critical
Target Milestone: 2.4.0
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-08-18 22:12 UTC by Jimmy [MSFT]
Modified: 2017-09-22 06:34 UTC (History)
6 users (show)

Tags: ac compilation netstandard xaml fr
Is this bug a regression?: Yes
Last known good build: 2.3.5-pre6


Attachments
repro project (25.24 KB, application/x-zip-compressed)
2017-08-18 22:12 UTC, Jimmy [MSFT]
Details


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:
Status:
RESOLVED FIXED

Description Jimmy [MSFT] 2017-08-18 22:12:35 UTC
Created attachment 24312 [details]
repro project

### Overview
A netstandard library with xaml pages does not compile after updating to 2.4.0-pre1. This happpens on both VS2017 and VS for Mac. Compilation fails with:

> C:\Program Files\dotnet\sdk\2.0.0-preview2-006497\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets(273,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. The duplicate items were: 'TestPage.xaml'


### Steps to Reproduce
1. Open the attached repro project in VS2017 or VS for Mac
2. Update the Xamarin.Forms package to 2.4.0-pre1
3. Build the project


### Expected Results
The project builds successfully.


### Actual Results
Compilation fails with the error above.


### Version Tests
2.4.0-pre1  BAD
2.3.5-pre6  GOOD
Comment 1 Nick Randolph 2017-08-24 05:20:34 UTC
You should be able to just remove the files in the exception from the csproj file - they are included by default so having them listed means that they're being duplicated (it would be better if VS was clever enough to work that out....).
Comment 2 Samantha Houts [MSFT] 2017-08-24 19:47:41 UTC
https://github.com/xamarin/Xamarin.Forms/pull/1112
Comment 3 Jason Smith [MSFT] 2017-08-29 18:13:31 UTC
Should be fixed in 2.4.0-pre2
Comment 4 Nick Randolph 2017-08-29 22:42:45 UTC
omg this supposed bug fix broke everything. For developers who had fixed the issue with pre1 by removing embedded resources from the csproj, this update has removed all the XAML files from every project. Seriously, was this fix even tested?
Comment 5 Pauli Jokela 2017-08-30 07:10:50 UTC
Does pre1/pre2 require a specific version of VS/VS4Mac in order to function properly?
Also what's the new/correct way of adding embedded resources (XAML, RESX)?
Comment 6 Kalpesh Chheda 2017-09-20 16:51:24 UTC
Same issue is now with pre3

Pre1 Bad
Pre2 Good
Pre3 Bad
Comment 7 Samantha Houts [MSFT] 2017-09-20 16:55:17 UTC
Kalpesh Chheda: Can you elaborate on your upgrade path? Did you go from pre2 to pre3? Are you using VS 2017 or VS for Mac? Do you see this issue with the sample project attached to this ticket? 

Thank you!
Comment 8 Kalpesh Chheda 2017-09-20 17:11:27 UTC
I have create new solution/project form visual studio 2017.15.3 
I have added new netstandard classlib.
Then I have moved XAML files to new netstandard project and deleted PCL project from the solution.
Then I have added Xamarin Forms 2.4.0-pre3 nuget package to netstandard project and while building I am getting below error

Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB3083	The item "App.xaml" was specified more than once in the "Resources" parameter and both items had the same value "GoodsManV2.App.xaml" for the "LogicalName" metadata.  Duplicate items are not supported by the "Resources" parameter unless they have different values for the "LogicalName" metadata.	GoodsManV2	C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets	84	


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'; 'Views\MainPage.xaml'	GoodsManV2	C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets	274
Comment 9 Kalpesh Chheda 2017-09-20 17:13:51 UTC
If I degrade package to Xamarin Forms 2.4.0-pre3 it builds fine.
Comment 10 Kalpesh Chheda 2017-09-20 17:14:13 UTC
I mean Xamarin Forms 2.4.0-pre2
Comment 11 Kalpesh Chheda 2017-09-22 05:21:03 UTC
Hey Samantha Houts.
Is this confirms bug in pre3?
Comment 12 Nick Randolph 2017-09-22 05:23:33 UTC
Hi all - please read the error message - you just need to remove the XAML files from the project file. pre2 actually broke the correct functionality of the csproj files, which has been fixed in pre3 (or so it appears). Unfortunately if you have been progressively using pre1, pre2 and now pre3 you will have been broken with each update
Comment 13 Kalpesh Chheda 2017-09-22 06:34:17 UTC
Ok I have removed and its working.

Thanks