microsoft / react-native-windows

A framework for building native Windows apps with React.
https://microsoft.github.io/react-native-windows/
Other
16.35k stars 1.14k forks source link

[0.74] New Architecture fails build with MDMERGE : error MDM2009: Duplicate type Microsoft.UI.Xaml.* when added some native libraries. #13597

Closed jihoobyeon closed 1 month ago

jihoobyeon commented 2 months ago

Problem Description

I am suffering same symptom as #7226, but build fails every time, not only first time. My app is 0.74 New architecture app, made by instructions mentioned here.

Steps To Reproduce

  1. Make a new RNW app with New architecture.
  2. Add npm packages react-native-permissions and @babylonjs/react-native-windows-0-71 to the app.
  3. Build it.

Expected Results

App should start.

CLI version

13.6.9

Environment

System:
  OS: Windows 10 10.0.19045
  CPU: "(4) x64 AMD Ryzen 3 2200U with Radeon Vega Mobile Gfx  "
  Memory: 24.25 GB / 31.63 GB
Binaries:
  Node:
    version: 20.10.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 3.6.4
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 10.8.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    AllowAllTrustedApps: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.22000.0
      - 10.0.22621.0
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 17.11.35219.272 (Visual Studio Community 2022)
Languages:
  Java: 21.0.3
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.5
    wanted: 0.74.5
  react-native-windows:
    installed: 0.74.16
    wanted: ^0.74.16
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Community Modules

"react-native-permissions": 4.1.5 "@babylonjs/core": 7.21.5 "@babylonjs/havok": 1.3.8 "@babylonjs/react-native": 1.8.6 "@babylonjs/react-native-windows-0-71": 1.8.6

Target Platform Version

10.0.19041

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

Debug

Snack, code example, screenshot, or link to a repository

No response

jihoobyeon commented 2 months ago

Hmm, I found that same native modules with old architecture also breaks. It says versions of NuGet package Microsoft.Windows.CppWinRT mismatches - seems to look like RNW is forcing to use specific version of C++/WinRT.

I'm not sure this two symptoms came from same bug, so I'm quite careful to either edit this issue or open another issue for old arch.

I tried building @babylonjs/react-native-windows-0-71 newly from source but that didn't solved the collision.

jonthysell commented 2 months ago

Sorry, we haven't really worked out the complete story/solution for new architecture apps to consume existing modules (esp. if those modules specify new native UI). So it's not really guaranteed that any existing module is set up in a way that it can be successfully consumed by new architecture apps (which is why the new templates are still experimental).

jonthysell commented 2 months ago

@marlenecota We use WinAppSDK in the new arch, it won't work when oplder modules still request WinUI 2 as a dependency, so we'll have to figure out how to support both in a future joint new/old arch module template and/or property sheets.

jihoobyeon commented 2 months ago

@marlenecota We use WinAppSDK in the new arch, it won't work when oplder modules still request WinUI 2 as a dependency, so we'll have to figure out how to support both in a future joint new/old arch module template and/or property sheets.

Oh, then do we have a way to disable WinUI 3 in New arch?

I'm now working at another, much simpler native module and it also has a problem with WinUI 3. so I just set UseWinUI3 to false in ExperimentalFeatures.props and got this error:

9>.\Composition.Input.idl(11): error MIDL2011: [msg]unresolved type declaration [context]: Microsoft.UI.Input.VirtualKeyStates [ Procedure 'GetKeyState' ( Interface 'Microsoft.ReactNative.Composition.Input.KeyboardSource' ) ] [C:\U
       sers\jihoobyeon\Desktop\fptest\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]
9>.\Composition.Input.idl(24): error MIDL2011: [msg]unresolved type declaration [context]: Microsoft.UI.Input.PhysicalKeyStatus [ Property 'KeyStatus' ( Interface 'Microsoft.ReactNative.Composition.Input.KeyRoutedEventArgs' ) ] [C:
       \Users\jihoobyeon\Desktop\fptest\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]
9>.\Composition.Input.idl(31): error MIDL2011: [msg]unresolved type declaration [context]: Microsoft.UI.Input.PhysicalKeyStatus [ Property 'KeyStatus' ( Interface 'Microsoft.ReactNative.Composition.Input.CharacterReceivedRoutedEven
       tArgs' ) ] [C:\Users\jihoobyeon\Desktop\fptest\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]

I'm still trying to find the window handle of RN app, but since I also have to use BabylonReactNative, I prefer not to use WinUI 3 if I can.

jihoobyeon commented 1 month ago

Hmm, I ported BabylonNative to Win32 from UWP, and now I can build the app. But now it fails with "remote debugging does not work with Babylon Native" even I disabled it with host.InstanceSettings().UseDirectDebugger(false);. I'll open a new issue for that.