Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Why can't I add my NuGet package to my app in Visual Studio?

$
0
0

I'm using Visual Studio for Mac on macOS Big Sur (11.2.3) to try to create a cross-platform NuGet package encapsulating common logic to be added to some Xamarin.Forms mobile apps.

I begin by creating a new solution and choosing Multiplatform -> Library -> Multiplatform Library. Under Target Platforms: I check the boxes for both iOS and Android. Under Implementation: I check Platform specific.

I add the platform-specific code to the iOS and Android projects, and shared code to the Shared directory, with no problem. The NuGet package builds without error.

But when I try to add the package to one of the Xamarin.Forms apps, VS raises the error Could not add packages and writes this to the package console:

Package <my package name> 1.0.0 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package <my package name> 1.0.0 supports:  - monoandroid11.0 (MonoAndroid,Version=v11.0)  - xamarinios10 (Xamarin.iOS,Version=v1.0)

I did try adding <TargetFramework>netstandard2.0</TargetFramework> to the .csproj files in the library projects, but that caused an explosion of errors that made it clear that was the wrong approach.

This is outside my existing expertise, and I'm at the end of my limited understanding. How do I build/modify this package so that it can be added to a mobile app solution?


Viewing all articles
Browse latest Browse all 3067

Trending Articles