Can't install NuGet package when target profiles DO match

DougCumbieDougCumbie USMember, University

I am getting the following error when trying to add my NuGet package to my project:

Could not install package ''. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework.

I am developing in Visual Studio 2015 on Windows 10 and have the latest version of Xamarin (v4.1.0.530) installed. What doesn't make sense is that my NuGet package is built using Profile111. So the above error doesn't really make sense.

I am using the NuGet Package Explorer to build my NuGet package, and the default folder name that gets created when I select the "profile111" platforms is "portable-net45+wp8+win8". I found that a workaround/hack to get my package added to my project was to create another lib subfolder with the same name as my Xamarin Forms package portable folder name... i.e. "portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10". Having this other folder lets me add the package and everything seems to work across all platforms with no issues.

Can anyone explain what this error really means and why my workaround works?

Thanks!

Answers

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @DougCumbie - I think the naming convention of your profile 111 its trying to get from might be incorrect. (Could be wrong)

    Have a look at http://embed.plnkr.co/03ck2dCtnJogBKHJ9EjY

    The Xamarin one you have shown is profile 259 with iOS and Android support.

  • iLearnXamariniLearnXamarin CHMember ✭✭

    Basically target of your NuGet package needs to match target of your project where you want to install NuGet package.

    One word about targeting PCLs, the more platform you choose to target, the less API is available, and the actual API that is available for you PCL is intersection of API of all selected platforms.

    1. Lets make it simple. Lest say that for NuGet package you specify that "portable-net45+win8".
    2. And lets say that the PCL project that where you want to use is targeting "portable-win+net45+wp80+win81+wpa81", this means that you have less API available than in "portable-net45+win8".

    So you can not install NuGet package from 1. in PCL from 2., the reason is very simple, PCL from 2 does not have all API that NuGet package from 1. have. Even if you could (by renaming folders), some thing would not work, for example if you used some API in NuGet from 1. that is really not available in PCL from 2. You will get exception.

    All this targeting is more like instruction to NuGet to respect this targeting. So, as a author of NuGet package, you should specify your targets, as a hint where your NuGet package could be used.

    This is how I understand whole story regarding targeting.

  • DougCumbieDougCumbie USMember, University

    Thanks for the feedback.

    @AdamP The naming convention for my profile111 is basically because the NuGet Package Explorer seems to be limited on what targets I can chose. But with the selections they provide, the closet thing I can get to profile111 gives "portable-net45+wp8+win8". (see attached image)

    @iLearnXamarin This is also how I understand the framework targeting. However, you provide some good additional insight. I think considering that my NuGet package is pretty simple and that my testing shows that it works on all platforms, my solution to rename the folder is ok.

    I guess the real question is how to properly create a NuGet package for a PCL. It seems that the name of the folder in the package is what dictates the profile. And like I said, the NuGet Package Explorer seems to be limited on what portable target profiles I can add to my package, so I guess I'd have to manually create the target folders to support other profiles. This link seems to explain it better:
    https://docs.nuget.org/create/enforced-package-conventions

  • iLearnXamariniLearnXamarin CHMember ✭✭

    I suggest you use nuget.exe pack , directly for crating nuget package, there you have full control of process. If you have any problems with nuspec, I can help

Sign In or Register to comment.