CsWin32 is a compile time package generating Win32 PInvoke from a list of name including wildcard.
You add a reference to Microsoft.Windows.CsWin32 (pre release as of time of writing) and then you just have to create a text file named NativeMethods.txt alongside your project file.
During next build, a source generator will generate all requested PInvoke inside a Windows.Win32.PInvoke class. Each recursively needed type is also included.
A NativeMethods.json file can be used to customize generation
microsoft/CsWin32: A source generator to add a user-defined set of Win32 P/Invoke methods and supporting types to a C# project.
Beware: An issue with source generator in WPF projects requires you some hacking.