This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 35582 - New build failure in SiteCore component sample against MSBuild 14
Summary: New build failure in SiteCore component sample against MSBuild 14
Status: RESOLVED FIXED
Alias: None
Product: Components
Classification: Xamarin
Component: Generation (show other bugs)
Version: Production (addons.xamarin.com)
Hardware: PC Windows
: High major
Target Milestone: ---
Assignee: Bill Holmes
URL:
Depends on:
Blocks:
 
Reported: 2015-11-05 11:42 UTC by Peter Collins
Modified: 2016-02-22 17:33 UTC (History)
4 users (show)

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


Attachments

Description Peter Collins 2015-11-05 11:42:20 UTC
I'm seeing a new issue in c6 builds when using the VS 2015 build tools. The SiteCore component fails to build due to:
> error CS1703: Multiple assemblies with equivalent identity have been imported

This project builds successfully in VS2015 and from command line with MSBuild 14 using cycle 5 builds, but fails with cycle 6 builds. This project builds successfully on Mac against cycle 6 builds, as well as in XS on windows against cycle 6 builds (which does not yet support 2015 build tools).

Steps to reproduce from Command line:
1. Download the SiteCore component
> https://components.xamarin.com/view/Sitecore.Mobile.SDK
2. Download xamarin-component.exe
> https://components.xamarin.com/submit/xpkg
3. xamarin-component.exe restore samples\AndroidMobileSdkDemo\AndroidMobileSdkDemo.sln
4. msbuild /t:SignAndroidPackage samples\AndroidMobileSdkDemo\AndroidMobileSdkDemo\AndroidMobileSdkDemo.csproj

Successful C5 build output:
https://gist.github.com/pjcollins/b59369d82f89ba289b86

Failed C6 build output:
https://gist.github.com/pjcollins/d596f7a09a46f9358105

##### Environment #####
Operating System: Windows 10
Repo Name: XamarinVS.git
Branch Name: cycle6
Build Revision: 8150bab699a83061f39a1cd5e35303e793972caa
MonoDroidHash: cycle6 2eefd39c431d80d2d004877f8ef84760b95d8e20
Comment 1 dean.ellis 2015-11-06 06:22:04 UTC
@peterc this is a problem with the nuget package  for the Sitecore 

 CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\PJ\Downloads\Sitecore.Mobile.SDK-1.0\samples\AndroidMobileSdkDemo\Components\Sitecore.Mobile.SDK-1.0\lib\android\System.Threading.Tasks.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\Facades\System.Threading.Tasks.dll'. Remove one of the duplicate references. [C:\Users\PJ\Downloads\Sitecore.Mobile.SDK-1.0\samples\AndroidMobileSdkDemo\AndroidMobileSdkDemo\AndroidMobileSdkDemo.csproj]
  CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\PJ\Downloads\Sitecore.Mobile.SDK-1.0\samples\AndroidMobileSdkDemo\Components\Sitecore.Mobile.SDK-1.0\lib\android\System.IO.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\Facades\System.IO.dll'. Remove one of the duplicate references. [C:\Users\PJ\Downloads\Sitecore.Mobile.SDK-1.0\samples\AndroidMobileSdkDemo\AndroidMobileSdkDemo\AndroidMobileSdkDemo.csproj]

It should NOT be including the design time facade dll's in the component package specifically

System.Threading.Tasks.dll
System.IO.dll

they appear be in be Components\Sitecore.Mobile.SDK-1.0\lib\android\ when they shouldn't be.

I don't know who maintains this component but they will need to update it to be compatible with the new build tooling. This isn't something we can fix on our end since its MSBuild doing the assembly resolution here not us. 

On a side note... its also including files like 

Newtonsoft.Json.dll
System.Net.Http.Extensions.dll
Microsoft.Threading.Tasks.dll

in the android folder of the package.. I'm willing to bet that if someone adds the nuget for Newtonsoft.json manually they will get the same error. 

The iOS and iOS unified lib folders have the same issue
Comment 3 dean.ellis 2015-11-06 11:06:53 UTC
Personally I don't think this is a regression. The previous build targets were hiding a problem that the user should fix. Namely the csproj had references to things like System.IO which were in the component directory and not just using the framework provided ones. Users should never reference Facade assemblies directly from an app because they are normally just shim's of the platform specific assembly provided by the actual framework.
Comment 4 dean.ellis 2015-11-09 11:35:04 UTC
To Summarise

The sample project included with the component should NOT be including the design time facade dll's in the component
package specifically

System.Threading.Tasks.dll
System.IO.dll

they appear be in be Components\Sitecore.Mobile.SDK-1.0\lib\android\. We probably don't need to include those files in the Component either.  

So to fix this issue we just need to remove the references for these assemblies from the .csproj of the component sample.

Interestingly on Mac.. we need to have a reference to System.Threading.Tasks.dll in order to build but not System.IO.. on windows they both need to be removed in order to the app to build. 
Both apps behave the same otherwise.
Comment 5 Peter Collins 2015-11-09 11:57:02 UTC
CC: @holmes @redth on Comment #4.

I'll be filing a new bug to track the behavioral discrepancy between various build paths here, as we will want to standardize on the "correct" behavior everywhere. Unfortunately, it looks like _none_ of this will be happening in time for cycle6-baseline.
Comment 6 Peter Collins 2016-01-27 18:24:06 UTC
Just for future reference, the mono bug filed mentioned in Comment 5 is: https://bugzilla.xamarin.com/show_bug.cgi?id=35706
Comment 7 Bill Holmes 2016-02-02 20:43:35 UTC
Peter,

Do you know if the NuGet works with Cycle 6?

https://www.nuget.org/packages/Sitecore.MobileSDK.Xamarin/

-Bill
Comment 8 Peter Collins 2016-02-03 19:57:27 UTC
The initial failure here was reported against cycle6, and it only affects the sample project that ships with the sitecore component, not the NuGet package itself.

Using a new or existing XA project, if I add and use the Sitecore.MobileSDK.Xamarin NuGet I'm able to compile and run my project without any issues.

However, the 'AndroidMobileSdkDemo' sample project errors out on machines with MSBuild 14 as mentioned above. It's only this sample project that will need to be updated to not reference the design time facade dll's in the component package, specifically:

System.Threading.Tasks.dll
System.IO.dll
Comment 9 Bill Holmes 2016-02-04 15:06:55 UTC

Given the dependencies that are contained in this component I suggest the submitter make use of the NuGet features now available in the component store.  

http://developer.xamarin.com/guides/cross-platform/advanced/submitting_components/components_and_nuget/

I will reach out to the submitter to resolve this issue.
Comment 10 Igor 2016-02-08 11:31:28 UTC
Hi all, Xamarin component had no dependency support when the package was created. 
That's why libraries was included in the component package. 
We will update package in a short time. 
Thanks.
Comment 11 Igor 2016-02-22 15:46:38 UTC
Hi all,

Please check the new Xamarin component version.
https://components.xamarin.com/view/sitecore.mobile.sdk

Now it's actually just a shell component around the NuGet Sitecore SDK package.
https://www.nuget.org/packages/Sitecore.MobileSDK.Xamarin/
Comment 12 Peter Collins 2016-02-22 17:33:39 UTC
Marking as resolved as per Comment #11, the included sample in v1.1 no longer fails to compile.

Note You need to log in before you can comment on or make changes to this bug.