CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

Merge multiple CsWinRT components together to reduce package size

Open lyf6lyf opened this issue 9 months ago • 3 comments

I am migrating a MFC C++ app to C#. I need to migrate several C++ components. I follow https://github.com/MichalStrehovsky/CppPublishAotReference to enable AOT.

It works well for the first component.

If I do same thing for the 2nd component, there will be two component dlls. Both of them contains the DotNet runtime code.

How can I merge the components into one dll, so that they can share the runtime code and reduce the package size?

I've tried solutions:

  1. Make project A and project B both CsWinRT component, and then let A reference B. It is Failed to build.
  2. Make project A CsWinRT component, and let A reference B. project A can be built, but the types in project B are not exported.
  3. Make CsWinRT component C, and let C reference A and B. In C, create proxy types for all public types in A and B. It can work, but requires many additional code.

lyf6lyf avatar Feb 06 '25 09:02 lyf6lyf