0
votes

Is it possible from a .NET 4.6.2 application to prefer .NET Standard version installation of a multi-target Nuget?

I have a .NET 4.6.2 application which is using a Nuget package built for both .NETFramework 4.6.2 and .NETStandard 2.0

When looking into the .csproj project file I can see this:

<Reference Include="CompanyAcme.TheNugetPackage.Client, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\TheNugetPackage.Client.2.1.4\lib\net462\CompanyAcme.TheNugetPackage.Client.dll</HintPath>
</Reference>

Which makes me think that my .NET 4.6.2 application is using the .NET 4.6.2 version of the Nuget package.

1
why do you want to do this? It is better to use the .net framework version of a lib to avoid DLL issuesmagicandre1981
I want to know if it's possible, I have a special situation where the .NET standard version of the nuget package doesn't have an old dependency which I can't include in my application.Jonas
as said, .net 4.6.x has those dependency issues, so you get more DLL in output. Microsoft added netfx config back to several libs to avoid this issue.magicandre1981

1 Answers

0
votes

You can do it with this filthy hack, but I'd certainly think twice before doing it

<PackageReference Include="Prism.Core" ExcludeAssets="Compile" GeneratePathProperty="true"> <Version>7.1.0.431</Version> </PackageReference>
<Reference Include="Prism"> <HintPath>$(PkgPrism_Core)lib\netstandard2.0\Prism.dll</HintPath> </Reference> 

From https://duanenewman.net/blog/post/a-better-way-to-override-references-with-packagereference/