I'm trying to update a library that is currently targeting .NET4.0 to:
- NETStandard 2.0
- NET4.5.2
using Multi-Targeting.
The dependent library I'm using is Microsoft.Build.Framework
. It's found either in two places:
NuGet
and min level is NET4.6- GAC via Full Framework (e.g.
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Build.Framework.dll
)
Because the nuget package min level is above 4.5.2, I can't use that nuget package in the 452 target.
So, is it possible to say: - When using NS20, please use the nuget package. - When using NET4.5.2, please use the GAC version.
thanks!
You can define your dependencies conditionally, depending on what current target framework the project is being built on. For that, you would adjust your project file to use the NuGet dependencies in one case, or standard non-NuGet references in the other case.
That would look like this:
So
net452
would get the normal assembly referenceMicrosoft.Build.Framework
with theReference
element, which can be resolved from the GAC or the local directory, and other frameworks will resolve it from NuGet using aPackageReference
.