Force nuget use .net framework 4.0 build instead of 4.5

I have a project that mixes .NET 4.5 and 4.0 projects.

Each time I update Newtonsoft.JSON or add a new package, projects 4.5 will refer to different assemblies than to .NET 4.0 projects:

<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net40" /> 

and .net 4.5 projects reference assembly 4.5:

  <package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" /> 

4.5 projects, however, refer to 4.0 projects, which leads to a build failure in the TFS assembly (because it creates everything in one folder), and when the assembly of Newtonsoft.Json.NET 4.5 ends in the build folder before the .NET 4.0 projects, it leads to Failure of projects targeting .NET 4.0.

Is there a way to get update-package to select targetFramework="net40" for all projects in the solution (even if the project is targeting .NET 4.5) (without the need to search and replace files after each update)?

Just like you can do with install-package -version?

+6
source share

Source: https://habr.com/ru/post/972020/


All Articles