I am working to move out NuGet references from using the packages.json format to PackageReferences. I have an issue with NuGet package compatibility: The package supports an older version of the .NET Framework.
This, using the packages.json format, works just fine.
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MarkdownDeep.NET-Signed" version="1.5" targetFramework="net461" />
</packages>
<Reference Include="MarkdownDeep, Version=1.5.5082.29984, Culture=neutral, PublicKeyToken=65640b2d9fe5ac0e, processorArchitecture=MSIL">
<HintPath>..\..\packages\MarkdownDeep.NET-Signed.1.5\lib\.NetFramework 3.5\MarkdownDeep.dll</HintPath>
<Private>True</Private>
</Reference>
However, replacing this with a PackageReference instruction in the .csproj file results in the error below:
<PackageReference Include="MarkdownDeep.NET-Signed">
<Version>1.5</Version>
</PackageReference>
"C:\Source\WebApp.csproj" (Restore target) (1) -> (Restore target) -> C:\Source\WebApp.csproj : error NU1202: Package MarkdownDeep.NET-Signed 1.5.0 is not compatible with net472 (.NETFramework,Version=v4.7.2). Package MarkdownDeep.NET-Signed 1.5.0 supports: netframework35 (.NetFramework 3.5,Version=v0.0)
Note that the current target framework in both cases is the same, v4.7.2.
Are there any additional instruction to add to the <PackageReference>
node that will allow me to indicate that it is OK for this to target .NET Framework 3.5?
Note:
There's some good info in Package references (PackageReference) in project files, but it seems it only deals with TargetFramework
as a variable to conditionally add references. I don't think I have a mix of .NET Framework versions to deal with - it's just v4.7.2 all the way.