Devolutions / MsRdpEx

Microsoft RDP Client Extensions
MIT License
178 stars 31 forks source link

Multi-target to net48 and .NET 8 instead of using netstandard2.0 target #101

Closed awakecoding closed 8 months ago

awakecoding commented 8 months ago

Modify project to target net48 and net8.0-windows, such that we can start using .NET 8 features through conditional compilation. The legacy RDP ActiveX COM Interop remains but has been refreshed - we'll keep them as close to the original generated assemblies, and eventually add an option not to import them from the nuget package to only use the modern COM Interop replacement only available using .NET 8 APIs.

The original COM Interop assemblies target .NET 4.0 + import WinForms. Actually, they simply lack a declared .NET Framework, so they're detected as .NET 4.0. AxInterop.MSTSCLib is built from the generated sources so it already targets the framework it is built for, but Interop.MSTSCLib is generated as an assembly, and cannot be rebuilt from source. I added a script that uses ildasm.exe, ilasm.exe to add the missing TargetFrameworkAttribute such that it could at least declare .NET 4.8. I've called it once on the generated assembly, and since we're using it as-is, this means it won't fake being .NET 8 when importing it in .NET 8. Still, it's better than leaving it as a .NET 4.0 with the annoying warning at build time for an unsupported target framework.

As for the rest, I've switched AxInterop.MSTSCLib to use generated assembly info, and found a way to include the original type library timestamp attribute. It's probably not used, but I'd rather stick as close as possible to the original to avoid trouble. I've kept nullable disabled on AxInterop.MSTSCLib because otherwise the generated code has too many warnings for nullable. One other reason why I've switched to generated assembly info is that otherwise it wouldn't get the target os platform attribute set to Window for net8.0-windows, and that would cause a lot of warnings as well.