0
votes

Im trying to create a nuget using the "Nuget Package Explorer". The project references 2 dlls witch target .net4.0 and the main dll targets .net4.5.

As specified, i put the 2 referenced dlls in a folder inside the "lib" folder called "net40", the main dll in a folder called "net45", then i pushed the nuget wich is located here

But when i try to install it in another project, it doesnt take any of the dlls !

Am I doing something wrong ?

Thank you.

UPDATE:

The nuget package contains:

lib (folder)
    net45 (folder)
        MainAssembly.dll -> targets .net_4.5
        Microsoft.VisualStudio.TextTemplating.10.0 -> targets .net_4
        Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 -> targets .net_4

notes:

  • MainAssembly needs the two other assemblies
  • I just want to target the .net version 4.5

the problem :

creating a nuget package using the structure above doesnt work, when intalling the nuget in a new project the MainAssembly is not added the list of references, only the two other assemblies are added.

1

1 Answers

0
votes

The project references 2 dlls witch target .net4.0 and the main dll targets .net4.5.

As specified, i put the 2 referenced dlls in a folder inside the "lib" folder called "net40", the main dll in a folder called "net45", then i pushed the nuget wich is located here

A NuGet package can target multiple .NET framework versions. However, a .NET project cannot.

Your dependent assemblies must be placed in the same .NET framework version folder in order for them to install into the target project. So, if you want your NuGet package to target 4.0 and 4.5, the structure should look like:

lib
    net40
        MainAssembly.dll
        DependentAssembly1.dll
        DependentAssembly2.dll
    net45
        MainAssembly.dll
        DependentAssembly1.dll
        DependentAssembly2.dll

The main assembly in each group must target the same framework version as the parent folder. The dependent assemblies can target any version the same or lower than the target version.

Note that typically each assembly is packaged as a separate NuGet package and the NuGet packages depend on each other, rather than putting the dependent assembiles into the same package.