14

My company has set up a nuget repository for packages that are proprietary to our business. I have a nuspec file for a package that lists dependencies that are located on the main nuget repository. When I install a package from our repository the dependencies are not installed.

<dependencies>
    <group targetFramework="uap">
        <dependency id="FluentNHibernate" version="2.0.3.0" />
        <dependency id="log4net" version="2.0.8.0" />
        <dependency id="Newtonsoft.Json" version="6.0.0.0" />
        <dependency id="UserModel.SMDC" version="1.0.0.0" />
    <dependency id="Microsoft.AspNet.Identity.Core" version="2.2.1" />
    <dependency id="Microsoft.AspNet.WebPages.Core" version="5.2.3" />
    <dependency id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" />
    <dependency id="Microsoft.AspNet.WebApi.Data" version="3.2.5" />
    <dependency id="Microsoft.AspNet.WebApi.WebData" version="3.2.5" />  
    <dependency id="Npgsql" version="3.2.5" />

    </group>
</dependencies>

Is there something I need to do to tell the "push" to look at the main nuget site?

Alan Floyd
  • 141
  • 1
  • 1
  • 6
  • Right now, all your dependencies are only for the target framework UAP (Universal Windows Platform). When you are installing the nuget package on a project, is that project targeting UAP? Do you expect this nuget package to install dependencies for any target framework? – techvice Dec 07 '17 at 23:59
  • That was copied from a site and I had no idea what to put there. I changed it to "net46". Thank you! – Alan Floyd Dec 08 '17 at 15:00

1 Answers1

16

The Dependencies section is you can specify the other nuget packages to target (as you are doing). Check out the Dependency Groups section in the first link. You likely have the wrong group type specified for your dependencies. Here is a list of the Target Frameworks. I would suspect you could remove the group tag and keep the <dependency> tags.

Here is an example of the dependencies (from your provided list):

<dependencies>
  <group>
    <dependency id="log4net" version="2.0.8.0" />
    <dependency id="Newtonsoft.Json" version="6.0.0.0" />
  </group>
  <group targetFramework="net46">
    <dependency id="log4net" version="2.0.8.0" />
    <dependency id="Newtonsoft.Json" version="6.0.0.0" />
    <dependency id="FluentNHibernate" version="2.0.3.0" />
    <dependency id="UserModel.SMDC" version="1.0.0.0" />
    <dependency id="Microsoft.AspNet.Identity.Core" version="2.2.1" />
    <dependency id="Microsoft.AspNet.WebPages.Core" version="5.2.3" />
    <dependency id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" />
    <dependency id="Microsoft.AspNet.WebApi.Data" version="3.2.5" />
    <dependency id="Microsoft.AspNet.WebApi.WebData" version="3.2.5" />  
    <dependency id="Npgsql" version="3.2.5" />
  </group>
</dependencies>

This example shows that we need log4net and Newtonsoft.Json as a non-specific group. This is what is used for all groups not specified as the target.

HackSlash
  • 4,944
  • 2
  • 18
  • 44
techvice
  • 1,315
  • 1
  • 12
  • 24
  • still does not work. What if the target application is 4.6.1? is that a problem? – Alan Floyd Dec 08 '17 at 16:17
  • i tried the example above and i get this error on push: element must not contain both and child elements. – Alan Floyd Dec 08 '17 at 16:36
  • I took the group out and get this error: Severity Code Description Project File Line Suppression State Error Some NuGet packages were installed using a target framework different from the current target framework and may need to be reinstalled. Visit http://docs.nuget.org/docs/workflows/reinstalling-packages for more information. Packages affected: Iesi.Collections, NHibernateProfiler.Appender, Npgsql, RestSharp, System.Data.SQLite.Core DASEE 0 – Alan Floyd Dec 08 '17 at 17:12
  • @AlanFloyd - I originally had an issue with my dependency code. I've updated it to fix the issue. As for the error you reported, open the package manager console and run `update-package -reinstall`. That should get you going. – techvice Dec 08 '17 at 17:52
  • `we need log4net and Newtonsoft.Json for all framework` That is wrong, for net46 they will not be used. Group without targetFramework is fallback group, not "shared" group. – smg Oct 26 '19 at 11:55