c# cmake版本中出现XAML文件冲突



我有一个c# CMake项目在这里,https://github.com/jarl-haggerty/cmake-test。它由两个库组成,其中包含一个UserControl1。Xaml,但使用不同的名称空间。如果我生成Visual Studio 2019解决方案并在构建两个库之间交替,则在构建库1时得到以下错误:

1>C:UsersjarlsourcerepostestOneUserControl1.xaml.cs(9,13,9,32): error CS0103: The name 'InitializeComponent' does not exist in the current context
1>C:Usersjarlsourcerepostestbuildobjx64DebugUserControl1.xaml(9,95,9,117): error CS1061: 'UserControl1' does not contain a definition for 'innerRect_MouseDownTwo' and no accessible extension method 'innerRect_MouseDownTwo' accepting a first argument of type 'UserControl1' could be found (are you missing a using directive or an assembly reference?)

如果我删除obj/x64/Debug中的所有文件,那么构建将再次开始工作。这个文件夹似乎是两个库中构建文件的目标,从错误中听起来像是UserControl的两个版本。Xaml混淆了。c++项目将把这些构建分离为一个。dir和2。dir文件夹。这是意料之中的吗?有解决办法吗?我正在尝试将一个Visual Studio项目与这样的几个案例移植到cmake.

如果我把add_library调用在单独的CMakeLists.txt文件(One/CMakeLists.txt和Two/CMakeLists.txt),那么构建在不同的文件夹中运行,这解决了我的问题。

最新更新