CsWinRT
CsWinRT copied to clipboard
Projection file disappears in WPF project
Describe the bug I would like to use CsWinRT in WPF the same way I use it in a WinUI project, but it doesn't build.
To Reproduce See my minimal repro at https://github.com/mmarczell-graphisoft/winrtbug
- Build and run the WinUI project. It builds and runs.
- Build the WPF project. It fails to build.
Expected behavior The WPF project should also build and run.
Actual behavior
As long as I do not have the using directive in my WPF C# code, nor any code using those definitions, the C# projection file does get generated under obj\Debug\net6.0-windows\Generated Files\CsWinRT
. However as soon as I enter the using directive and rebuild, this file is no longer there.
Version Info CsWinRT 2.0.7 net6.0-windows
@smourier has provided a workaround which can be seen here: https://stackoverflow.com/questions/78316887/use-c-winrt-component-but-really-any-winrt-component-in-wpf-net-6/78342481#78342481
or here: https://github.com/mmarczell-graphisoft/winrtbug/commit/e417f57079c68c18f4ca530311b150ee47d2fcd0
but this is only a workaround, the bug still stands.
Looking at cswinrt.rsp
(which is a file that contains the command line arguments), I can observe that as long as my C# code does not contain using winrtcomponent_cpp;
, the rsp file contains
-input "C:\Dev\git\winrtbug\_build\x64\Debug\winrtcomponent.cpp\bin\winrtcomponent.cpp\winrtcomponent_cpp.winmd"
but if I enter the using directive, that line in the rsp becomes empty.
- input