Forum Xamarin.iOS

portable-net45+sl5+win8+wpa81+wp8 and xamarinmac20

tofutimtofutim USUniversity ✭✭
edited January 2017 in Xamarin.iOS

Hi, I am trying to install SignalR.Client (Microsoft.AspNet.SignalR.Client) via nuget to a xamarinmac20 app/library and it is failing. It is failing because Xamarin Studio does not recognize 'portable-net45+sl5+win8+wpa81+wp8' as valid for adding into Xamarin Mac Mobile Framework. However, this should be supportable since it is Profile 344, and you can create a Profile 344 PCL and add it as a reference to a xamarinmac20. A workaround is to change the nuspec to target netstandard11, but 'portable-net45+sl5+win8+wpa81+wp8' is a subset of netstandard11 and should work out of the box.

Retrieving package 'Microsoft.AspNet.SignalR.Client 2.2.1' from 'nuget.org'.
For adding package 'Microsoft.AspNet.SignalR.Client.2.2.1' to project 'Eggs' that targets 'xamarinmac20'.
Install failed. Rolling back...
Package 'Microsoft.AspNet.SignalR.Client.2.2.1' does not exist in project 'Eggs'
Package 'Microsoft.AspNet.SignalR.Client.2.2.1' does not exist in folder '/Users/tim/Projects/Eggs/packages'
Executing nuget actions took 147.87 ms
Could not install package 'Microsoft.AspNet.SignalR.Client 2.2.1'. You are trying to install this package into a project that targets 'Xamarin.Mac,Version=v2.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I made a test package that has lib\portable-net45+sl50+win+wpa81+wp80 (like SignalR) and also tried lib\portable-net45+sl5+win8+wpa81+wp8 to no avail:

For adding package 'Test.Package.1.0.0' to project 'TesteMe' that targets 'xamarinmac20'.
Install failed. Rolling back...
Package 'Test.Package.1.0.0' does not exist in project 'TesteMe'
Package 'Test.Package.1.0.0' does not exist in folder '/Users/tim/Projects/TesteMe/packages'
Could not install package 'Test.Package 1.0.0'. You are trying to install this package into a project that targets 'Xamarin.Mac,Version=v2.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

This problem persists in the latest Beta Channel. In my particular case, I have to choose Xamarin Mac Mobile Framework because I need System.Security.Cryptography.Algorithms from .NET 4.6. (I know it can be installed if I go backwards to .NET 4.5.)

Tagged:

Answers

  • mattwardmattward GBMember Xamurai

    I tried to install Microsoft.AspNet.SignalR 2.2.1 into a Xamarin.Mac 2.0 project using Xamarin Studio 6.1.3 and it fails with:

    Could not install package 'Microsoft.Owin.Host.SystemWeb 2.1.0'. You are trying to install this package into a 
    project that targets 'Xamarin.Mac,Version=v2.0', but the package does not contain any assembly references or
    content files that are compatible with that framework. For more information, contact the package author.
    

    Looking at the Microsoft.Owin.Host.SystemWeb 2.1.0 NuGet package it only contains assemblies for .NET 4.0 and .NET 4.5. So that is not compatible with Xamarin.Mac 2.0.

    Looking at the Microsoft.AspNet.SignalR 2.2.1 NuGet package it also only contains assemblies for .NET 4.5. So it is not compatible with Xamarin.Mac 2.0.

    Is that the same NuGet package you are trying? Or are you installing a different one?

    Right now the only workaround I see is to change the Xamarin.Mac project to target .NET 4.5 in the project options - Build - General.

  • tofutimtofutim USUniversity ✭✭
    edited January 2017

    No I'm sorry, I meant SignalR client. Install Microsoft.AspNet.SignalR.Client. I will update the original post.

    I know that the client can be installed by switching to .NET 4.5 but I need to stay on the Mobile Framework because of some components from .NET 4.6. I believe that it is a bug that Profile 344 ('portable-net45+sl5+win8+wpa81+wp8') nuget packages cannot be installed since this is obviously a subset of netstandard1.1. Also, you can create a Profile 344 PCL in Xamarin Studio and reference it in xamarinmac20.

    Just saw your blog http://lastexitcode.com/ - you are the man! Thanks for looking into this.

    Here is what the .Client nuspec looks like:

    <?xml version="1.0"?>
    <package>
      <metadata>
        <id>Microsoft.AspNet.SignalR.Client</id>
        <title>Microsoft ASP.NET SignalR .NET Client</title>
        <version>__SIGNALR_PACKAGE_VERSION__</version>
        <authors>Microsoft</authors>
        <owners>Microsoft</owners>
        <licenseUrl>__SIGNALR_CLIENT_LICENSE_URL__</licenseUrl>
        <copyright>__SIGNALR_COPYRIGHT_NOTICE__</copyright>
        <projectUrl>http://www.asp.net/signalr</projectUrl>
        <requireLicenseAcceptance>true</requireLicenseAcceptance>
        <description>.NET client for ASP.NET SignalR.</description>
        <language>en-US</language>
        <tags>Microsoft AspNet SignalR AspNetSignalR Client</tags>
        <releaseNotes>https://github.com/SignalR/SignalR/releases</releaseNotes>
        <dependencies>
          <group targetFramework="net40">
            <dependency id="Newtonsoft.Json" version="6.0.4" />
          </group>
          <group targetFramework="net45">
            <dependency id="Newtonsoft.Json" version="6.0.4" />
          </group>
          <group targetFramework="portable-net45+sl5+netcore45+wp8+wp81">
            <dependency id="Newtonsoft.Json" version="6.0.4" />
            <dependency id="Microsoft.Net.Http" version="2.2.28" />
          </group>
          <group targetFramework="wpa81">
            <dependency id="Newtonsoft.Json" version="6.0.4" />
            <dependency id="Microsoft.Net.Http" version="2.2.28" />
          </group>
        </dependencies>
      </metadata>
      <files>
        <file src="Net40\Microsoft.AspNet.SignalR.Client.dll" target="lib\net40" />
        <file src="Net40\Microsoft.AspNet.SignalR.Client.xml" target="lib\net40" />
        <file src="Net45\Microsoft.AspNet.SignalR.Client.dll" target="lib\net45" />
        <file src="Net45\Microsoft.AspNet.SignalR.Client.xml" target="lib\net45" />
        <file src="portable-net45+sl50+win+wpa81+wp80\Microsoft.AspNet.SignalR.Client.dll" target="lib\portable-net45+sl50+win+wpa81+wp80" />
        <file src="portable-net45+sl50+win+wpa81+wp80\Microsoft.AspNet.SignalR.Client.xml" target="lib\portable-net45+sl50+win+wpa81+wp80" />
        <file src="portable-win81+wpa81\Microsoft.AspNet.SignalR.Client.dll" target="lib\portable-win81+wpa81" />
        <file src="portable-win81+wpa81\Microsoft.AspNet.SignalR.Client.xml" target="lib\portable-win81+wpa81" />
        <file src="netcore50\Microsoft.AspNet.SignalR.Client.dll" target="lib\netcore50" />
        <file src="netcore50\Microsoft.AspNet.SignalR.Client.Xml" target="lib\netcore50" />
      </files>
    </package>
    

    Xamarin Studio is not recognizing portable-net45+sl50+win+wpa81+wp80 as valid for xamarinmac20, which it really should be.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    Try the component, https://components.xamarin.com/view/signalr, which does have a mac-unified .dll.

  • mattwardmattward GBMember Xamurai

    OK I can reproduce the problem now.

    This looks like a problem with NuGet 3. Older versions of Xamarin Studio, such as version 6.0, use NuGet 2 and you can install Microsoft.AspNet.SignalR.Client 2.2.1 into a Xamarin.Mac project with that version.

    With NuGet 3 the portable class library profiles that are supported by Xamarin projects are hard coded. It looks Xamarin.Mac is not included in this list so NuGet 3 believes it is not compatible with any portable class library framework. So NuGet will need to be modified to allow this.

    NuGet 2 checks for a target framework that started with Xamarin and then looked in the portable class library profile xml files on the machine to see if things were compatible.

  • tofutimtofutim USUniversity ✭✭
    edited January 2017

    I can see that. Looks like xamarinmac20 got totally ignored. Oddly netframework1.1 can be installed in xamarinmac20.

    ** Added nuget issue **
    https://github.com/NuGet/Home/issues/4454

    Matt, if there is a way I can get an updated Nuget, can I swap it in? Or is nuget hard coded into Xamarin Studio?

  • tofutimtofutim USUniversity ✭✭
    edited January 2017

    Matt, in the nuget code base there is a list
    https://github.com/NuGet/NuGet.Client/blob/4cccb13833ad29d6a0bcff055460d964f1b49cfe/src/NuGet.Core/NuGet.Frameworks/DefaultFrameworkMappings.cs

    Is 'xamarinmac' sufficient, or do they also need to add 'xamarinmac20'

                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.MonoAndroid, "monoandroid"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.MonoTouch, "monotouch"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.MonoMac, "monomac"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinIOs, "xamarinios"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinMac, "xamarinmac"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation3, "xamarinpsthree"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation4, "xamarinpsfour"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinPlayStationVita, "xamarinpsvita"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinWatchOS, "xamarinwatchos"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinTVOS, "xamarintvos"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinXbox360, "xamarinxboxthreesixty"),
                                new KeyValuePair<string, string>(FrameworkConstants.FrameworkIdentifiers.XamarinXboxOne, "xamarinxboxone"),
    

    (Wait, there is Xamarin Playstation?!?!!?)

  • mattwardmattward GBMember Xamurai

    Thanks. I was just going to open a NuGet bug report and you did it for me already.

    The other mappings in DefaultFrameworkMappings are for .NET Standard which I think you found was working. So I think it is only needed in the DefaultPortableFrameworkingMappings.

  • mattwardmattward GBMember Xamurai

    Which version of Xamarin Studio are you using? With Xamarin Studio 6.1 I think I could patch NuGet for you and you could replace the .dll directly. Xamarin Studio 6.2 is more tricky since we are currently using the official binaries and I have not tried compiling those.

  • mattwardmattward GBMember Xamurai

    @tofutim - There are patched NuGet binaries available for Xamarin Studio 6.2 on GitHub:

    https://github.com/mrward/nuget-binary/tree/3.5.0-xamarinmac-pcl-support
    

    You may need to unblock them if you download them directly from NuGet. I cloned the repository so avoided this.

    Then take a backup of your Xamarin Studio.app in Applications and then copy all the binaries, apart from nuget.exe, into the folder:

    /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.PackageManagement
    

    Then you should be able to install PCLs into Xamarin.Mac projects without changing the project's target framework.

Sign In or Register to comment.