Reputation: 1
We're trying to gradually transition projects from .NET 4x to .NET 8.
We've got some dependencies that are windows-only. So, to target newer .net versions we have to use the net8.0-windows
target instead of net8.0
or a netstandard version like netstandard2.0
.
This seems like it should be straightforward. Just multi-target the two desired frameworks in the project
<TargetFrameworks>net472;net8.0-windows</TargetFrameworks>
But, this causes the following build errors
'TargetPlatformAttribute' is inaccessible due to its protection level
'SupportedOSPlatformAttribute' is inaccessible due to its protection level
It appears that the compiler is automatically generating an AssemblyInfo.cs with these attributes to denote the target platform.
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]
However, those attributes aren't available until .NET 5+ This causes build errors for the .NET 4.7.2 version of the project.
Anyone know a good work around?
Upvotes: 0
Views: 75