Build has broken by adding a Nuget package which uses Microsoft.NETCore.Portable.Compatibility

hygehyge Member ✭✭

Hi, I'm a new developer for Xamarin.Forms.

Last night, I've created new Xamarin.Forms app with Android only.
It was builded successfully on first time, but after I added 'Combinatorics' package, the build is broken.

Belows are logged errors.
CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll' and 'C:\Users\User\.nuget\packages\microsoft.netcore.portable.compatibility\1.0.1\ref\netstandard1.0\mscorlib.dll'. Remove one of the duplicate references.

And related on this error, there are many errors like
Resources/Resource.designer.cs(12,36): error CS0731: The type forwarder for type 'System.Attribute' in assembly 'System.Runtime' causes a cycle
and
Resources/Resource.designer.cs(409,17): error CS0518: Predefined type 'System.Int32' is not defined or imported

'Combinatorics' package depends on 'Microsoft.NETCore.Portable.Compatibility' and I can't remove this dependency.

Is there any solution for this?
Attached file is repro of this issue and here is my environment.

Microsoft Visual Studio Professional 2017
Version 15.5.7
VisualStudio.15.Release/15.5.7+27130.2036
Microsoft .NET Framework
Version 4.7.02556

Visual C# 2017 00370-20007-76118-AA391

Merq 1.1.17-rc (cba4571)

Mono Debugging for Visual Studio 4.8.4-pre (3fe64e3)

NuGet Package Manager 4.5.0

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Xamarin 4.8.0.760 (fc93f3f5b)
Xamarin.iOS と Xamarin.Android の開発を有効にする Visual Studio 拡張機能

Xamarin Designer 4.8.188 (c5813fa34)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK 8.1.5.0 (HEAD/75f8c6838)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK 11.6.1.4 (db807ec)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

ユニバーサル Windows アプリ用 Visual Studio Tools 15.0.27130.2036
ユニバーサル Windows アプリ用 Visual Studio Tools を使用すると、電話、タブレット、PC など、Windows 10 を実行している各デバイスで使用できるユニバーサル アプリの単一ビルドを利用できます。これには Microsoft Windows 10 ソフトウェア開発キットが含まれています。

Please help!

Best Answer

  • hygehyge ✭✭
    Accepted Answer

    I temporary resolved this isuue by following this(ttps://github.com/TorbenK/TK.CustomMap/issues/131#issuecomment-257271077).
    (can't post link yet ...)

    <dependencies>
      <group targetFramework=".NETStandard1.2">
        <!--dependency id="Microsoft.NETCore.Portable.Compatibility" version="1.0.1" exclude="Build,Analyzers" /-->
        <dependency id="NETStandard.Library" version="1.6.0" exclude="Build,Analyzers" />
      </group>
    </dependencies>
    

    After doing this, the build success.

    But I'm still looking for the 'right' solution.
    Any information is appreciate.

Answers

  • hygehyge Member ✭✭
    Accepted Answer

    I temporary resolved this isuue by following this(ttps://github.com/TorbenK/TK.CustomMap/issues/131#issuecomment-257271077).
    (can't post link yet ...)

    <dependencies>
      <group targetFramework=".NETStandard1.2">
        <!--dependency id="Microsoft.NETCore.Portable.Compatibility" version="1.0.1" exclude="Build,Analyzers" /-->
        <dependency id="NETStandard.Library" version="1.6.0" exclude="Build,Analyzers" />
      </group>
    </dependencies>
    

    After doing this, the build success.

    But I'm still looking for the 'right' solution.
    Any information is appreciate.

  • DamianSuessDamianSuess USMember ✭✭
    edited April 2018

    @hyge, to clear things up, the changes were made to the NuGet package's .nuspec file, correct?

    @hyge said:
    I temporary resolved this isuue by following this (https://github.com/TorbenK/TK.CustomMap/issues/131#issuecomment-257271077).
    (can't post link yet ...)

    <dependencies>
      <group targetFramework=".NETStandard1.2">
        <!--dependency id="Microsoft.NETCore.Portable.Compatibility" version="1.0.1" exclude="Build,Analyzers" /-->
        <dependency id="NETStandard.Library" version="1.6.0" exclude="Build,Analyzers" />
      </group>
    </dependencies>
    

    After doing this, the build success.

    But I'm still looking for the 'right' solution.
    Any information is appreciate.

  • hygehyge Member ✭✭
    edited April 2018

    @DamianSuess , Yes, I edited the .nuspec file at "{UserDir}\.nuget\packages\combinatorics\1.1.0.19\combinatorics.nuspec".

Sign In or Register to comment.