Skip to content

New arch app first builds sometimes fail with circular dependency error MSB4006 #13599

@jonthysell

Description

@jonthysell

Problem Description

While updating the new arch templates for apps and libs to use the new arch NuGets packages (see PR #13338), we sometimes hit the following error:

.nuget\packages\microsoft.windows.cppwinrt\2.0.230706.1\build\native\Microsoft.Windows.CppWinRT.targets(228,13): error MSB4006: There is a circular dependency in the target dependency graph involving target "CppWinRTComputeGetResolvedWinMD".

This appears to be a known issue in CppWinRT when using a Windows Packaging project that relies on any projects that use CppWinRT: microsoft/cppwinrt#950. If projects are built fast enough and in parallel, you end up in a situation where CppWinRT gets confused when generating headers.

My guess is this is only reproing now with the switch to NuGets for the new architecture templates, which drastically speeds up their builds. This only affects the first build, if you build a 2nd time it usually works because the headers for one project will already be done.

Otherwise, the only solid workaround is to disable multi-proc builds by passing --singleproc to run-windows.

Steps To Reproduce

  1. Create a new library project with create-react-native-library WITH an example app
  2. Add RNW and then add the windows project with init-windows --template cpp-lib
  3. NAvigate to the example app folder and try to build with run-windows.

Expected Results

The example app builds successfully the first time.

CLI version

14.0.0-alpha.11

Environment

info Fetching system and libraries information...
System:
  OS: Windows 11 10.0.26100
  CPU: "(24) x64 AMD Ryzen Threadripper PRO 3945WX 12-Cores     "
  Memory: 46.27 GB / 63.86 GB
Binaries:
  Node:
    version: 18.18.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 3.6.1
    path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm:
    version: 9.8.1
    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.22621.0
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 17.12.35209.166 (Visual Studio Enterprise 2022)
    - 17.11.35208.52 (Visual Studio Enterprise 2022)
Languages:
  Java: Not Found
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.0.0-rc-fb9a90fa48-20240614
    wanted: 19.0.0-rc-fb9a90fa48-20240614
  react-native:
    installed: 0.76.0-nightly-20240821-387560a9a
    wanted: nightly
  react-native-windows:
    installed: 0.0.0-canary.857
    wanted: 0.0.0-canary.857
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: false
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Community Modules

No response

Target Platform Version

10.0.22621

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

Debug

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App TemplateExternalIssue tracked in this repo but change will need to happen in another repoNew ArchitectureBroad category for issues that apply to the RN "new" architecture of Turbo Modules + FabricScenario: Visual StudioWorkstream: Developer ExperienceSupport the RNW developer inner-loop.bug

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions