Search code examples
.netnugetnuget-packagenuget-spec

Simplest way to target multiple framework in nuget?


I created a library that uses: generics, extension methods and Func delegate. Func delegate is most new feature to .NET (version 3.5) in the library. When I published it to nuget, the project was targeting the .NET version 4.5.2 but when I tried to install it to a project that target version 4.5, it failed.

How to ensure that the package will be installed on any project that targets .NET 3.5 and later versions, should I change the target framework in the library to 3.5 or I should use the directory convention, and create separate dll for every framework, explained here:

Supporting multiple .NET framework versions


Solution

  • Target the package for 3.5 which means the lib folder should be like this.

    lib\net35

    If a package targets net35, it can be installed in any project that targets .NET 3.5 or above.