microsoft / CsWinRT

C# language projection for the Windows Runtime
MIT License
553 stars 106 forks source link

[R2R | CsWinRT Component] Allow CsWinRT component to deploy .NET dlls as ready to run. #1523

Open RobsonPontin opened 8 months ago

RobsonPontin commented 8 months ago

Hello.

Summary

In an architecture where we have a WinUI 3 C++ application and a CsWinRT component dependency, we would like to have a simple way to deploy it as ready to run to reduce JIT time and improve performance.

Rationale

Since Windows App SDK does not support Native AOT yet, and for any other reason, a native C++ application might be a good approach to reduce overhead of loading .NET runtime dlls during app launch.

With this, as far as I know, there is not a way to allow the C++ app to use publish profiles and therefore deploy it as ReadyToRun.

At the moment I achieved this by:

  1. Building the entire solution with msbuild.exe
  2. Manually building the CsWinRT component by using msbuild.exe + publish profiles in it,
  3. Manually copying all dlls that got ReadyToRun (usually double of the size now) and replace it the ones from first build.

Important Notes

Here is a sample project for your reference of a similar architecture:

image

Open Questions

  1. Could this be possible by building the C++ App directly with msbuild?
  2. Could this be also available on VS?
  3. If this is possible what could be a timeline?
dongle-the-gadget commented 8 months ago

ReadyToRun doesn't support native DLLs AFAIK.

hez2010 commented 8 months ago

I think it's already possible to use R2R together with CsWinRT for a C# WinRT component?