0

I have a Xamarin Forms app which was built with PCL.

When installing NuGet packages I would see all packages installed in NuGet Explorer.

Example Android Project:

Xam.Plugin.Geolocator **5.0.0.187-beta**

It might rely on the following NuGets:

enter image description here

However, when I install Xam.Plugin.Geolocator in the .NET Standard 2.0 solution I don't see the other plugins in the Nuget Package Explorer like I did in PCL project.

Regardless, the Forms App works just fine. Why don't the dependency package show up anymore? How can I know what version of the dependency packages I have installed?

I've gone ahead and manually installed them to the .NET Standard project, but that doesn't feel correct...

Additionally, I've noticed there is no longer a Packages folder in any of my Projects.

In my PCL Solution, I could see the dependencies. See Below:

enter image description here

aherrick
  • 19,799
  • 33
  • 112
  • 188

1 Answers1

2

There should be a Dependencies - NuGet folder for a .NET Standard SDK style project. There is no Packages folder for an SDK style project.

You can expand the Dependencies - NuGet folder items to see the dependencies. If there are no child nodes then there are no dependencies.

You can also see more detailed information in the project.assets.json file which is created in the obj directory after restoring the NuGet packages.

Xam.Plugin.Geolocator has just the .NET Standard.Library NuGet package as a dependency if you are installing it into a .NET Standard project. This NuGet package would be referenced by default in a .NET Standard project. When I install that into a .NET Standard 2.0 project in Visual Studio 2017 it shows no dependencies.

The full set of dependencies taken from the .nuspec file is:

<dependencies>
  <group targetFramework=".NETFramework0.0" />
  <group targetFramework="Windows0.0" />
  <group targetFramework="WindowsPhone0.0" />
  <group targetFramework="WindowsPhoneApp0.0" />
  <group targetFramework=".NETStandard1.0">
    <dependency id="NETStandard.Library" version="1.6.1" />
  </group>
  <group targetFramework="MonoAndroid1.0">
    <dependency id="Xamarin.GooglePlayServices.Location" version="60.1142.0" />
    <dependency id="Plugin.Permissions" version="2.2.1" />
  </group>
  <group targetFramework="Xamarin.iOS1.0">
    <dependency id="Plugin.Permissions" version="2.2.1" />
  </group>
  <group targetFramework="Xamarin.Mac2.0" />
  <group targetFramework=".NETPortable0.0-Profile259" />
  <group targetFramework="UAP0.0" />
  <group targetFramework=".NETPlatform5.0" />
  <group targetFramework="Xamarin.TVOS0.0" />
  <group targetFramework="Xamarin.WatchOS0.0" />
</dependencies>

If you try other NuGet packages, such as say AutoMapper, then you will dependencies when you expand the Dependencies - NuGet - AutoMapper item in the Solution Explorer.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • Hi thanks for the response. See my updated answer. In the PCL days, I would see those 4 dependencies as NuGets including their version in the "Manage NuGet Packges for Solution" window. – aherrick Mar 14 '18 at 23:42
  • @aherrick - It has those Google Play Service dependencies for Android projects not for PCL projects. If you unzip the .nupkg you can see the structure of the Xam.Plugin.Geolocator NuGet package. I suspect NuGet is just getting a license approval for all dependencies just in case they are used. – Matt Ward Mar 15 '18 at 16:34
  • Right, but the point is how do I know what version is being installed? Previously those Google Play Service dependencies could be seen in my NuGet package view which showed the version. They could also then be upgraded independently if needed. Hopefully I'm making sense. See my edit above with the screenshot. – aherrick Mar 15 '18 at 17:05
  • You should be able to see the version of the dependencies if you select one and open the Properties window. Also you cannot upgrade the dependencies directly if they are not PackageReferences in your project. You can update the dependencies directly used as PackageReferences in your project which may or may not update any child dependencies. The .NET Standard projects do not add PackageReferences into your project for all the dependencies, unlike when you use packages.config, only those that you install. – Matt Ward Mar 16 '18 at 09:58
  • In my mind the problem there is what if there are multiple NuGets that reference the same DLLs? And you want to ensure you upgrade all the dependencies? – aherrick Mar 16 '18 at 18:59
  • If you explicitly install all the dependencies you can have more control. However this makes the use of PackageReference less useful. https://blog.nuget.org/20170316/NuGet-now-fully-integrated-into-MSBuild.html – Matt Ward Mar 17 '18 at 11:33