C. Carter
C. Carter

Reputation: 291

Nuget Dependencies not being added to the project

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?

Upvotes: 0

Views: 1006

Answers (1)

Matt Ward
Matt Ward

Reputation: 47907

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.

Upvotes: 2

Related Questions