I have a problem starting with VS2017 and the new PackageReference for NuGet dependencies.
At first I was excited that this extra packages.config file is not needed anymore. But now I am a bit disappointed:
Some of my assemblies target framework 4.0 because they must be able to run under XP also. Others do not have this limitation and target framework 4.6.1. This works fine because no 4.0 assembly have a dependency on a 4.6.1 assembly. Only the other direction.
Most assemblies uses the NLog NuGet package. But when using the new PackageReference option for specifying the NuGet packages, the assemblies targeting framework 4.6.1 will always install the NLog variant targeting .NET 4.5. From then on, other assemblies depending on a .NET 4.0 assembly cannot be build anymore:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3275: The primary reference "Tools, Version=2.0.0.9180, Culture=neutral, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "NLog, Version=3.2.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c" which was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0". [D:\Work\4.8.0_PackageReference\Test\TestApp.csproj]
I want to use NLog for .NET 4.0 for all projects. Is this really not possible without packages.config? There one could specify the desired framework with the targetFramework attribute. But I could not find any way to do this with the new PackageReference approach. That is unbelievable...
Specific Version
totrue
. sometimes you have to do it directly in proj file as VS might revert to "corresponding version" (to selected target framework) – T.S.bin
. Then folder namedmyassebly
. Then GAC. you can also in config file, set your probing order. So, if your proj FW 4.5, you need to set reference to lower one and [probably] set "specific version". docs.microsoft.com/en-us/dotnet/framework/deployment/… – T.S.