0

So recently I replaced my PCL with a .Net Standard 2.0 one (Created a new solution and replaced the old one).

Previously (when the project was PCL) I created a nuget package from the project and installed it to my Xamarin Forms project. The nuget package would automatically download the Dependencies listed in the nuspec and add them to the appropriate projects' References (i.e correct libraries would go to the android project or iOS project).

With a .Net Standard Shared Library, this no longer seems to work which is very peculiar. Nuget says that it installs the dependencies to the project successfully but it does not add them as references.

Here is the nuspec dependencies section

<dependencies>
                    <group targetFramework="MonoAndroid1.0">
                        <dependency id="Serilog.Sinks.Xamarin" version="0.1.29" />
                        <dependency id="Xamarin.Firebase.JobDispatcher" version="0.7.0-beta1" />
                    </group>
                    <group targetFramework="Xamarin.iOS1.0">
                        <dependency id="Serilog.Sinks.Xamarin" version="0.1.29" />
                    </group>
                    <group targetFramework=".NETStandard2.0">
                        <dependency id="Serilog" version="2.6.0" />
                        <dependency id="Serilog.Sinks.File" version="4.0.0" />
                        <dependency id="Serilog.Sinks.Console" version="3.1.1" />
                        <dependency id="Newtonsoft.Json" version="10.0.3" />
                    </group>
        </dependencies>

Part of me wonders if there is some issue with .Net Standard and Nuget or if i've run into a weird issue with my target frameworks?

C. Carter
  • 291
  • 2
  • 11

1 Answers1

2

When you install a NuGet package into a sdk style .NET Standard 2.0 project no references will be directly added to your project file (.csproj). Instead just a PackageReference will be added. The assemblies from the NuGet package will still be used at build time but will not be added directly to the project file directly.

NuGet will also only add the single PackageReference for the package installed. Unlike using a packages.config file it will not add all the dependencies to your project file but they will be implicitly used.

More information about what assemblies and dependencies have been resolved for your project can be found in the obj/project.assets.json file which is generated on NuGet restore.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • This comment made me realise the actual issue I had wasn't the references but something else. Reading the project.assets.json file lead me to the discovery that certain packages weren't being installed. I assumed that it was related to the fact that the dependencies weren't appearing explicitly but turns out the nuget cache was the culprit! Thanks a tonne! – C. Carter Dec 17 '17 at 21:09