microsoft / react-native-windows

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

Barebones React-Native-Windows project will not build #12134

Closed Hareesh-S-T closed 3 months ago

Hareesh-S-T commented 1 year ago

Problem Description

Visual Studio Build Tools 2019 - 16.11.30 Visual Studio Community 2022 - 17.7.4 NodeJS - 20.5.1 JDK - 20.0.1 React Native - 0.72.4

After initializing a new RN project and installing the React-Native for Windows packages, running on UWP fails with the following error -

× Building Solution: C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\XamlCompiler\Microsoft.Windows.UI.X... × Build failed with message ...\node_modules\react-native-windows\build\x64\Debug\Microsoft.ReactNative\Generated Files\winrt\Windows.UI.Xaml.h(14,10): fatal error C1083: Cannot open include file: 'winrt/impl/Windows.ApplicationModel.DataTransfer.DragDrop.2.h': No such file or directory

--logging gives me the following -

fatal error C1083: Cannot open include file: 'winrt/impl/Windows .ApplicationModel.DataTransfer.DragDrop.2.h': No such file or directory C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\XamlCompiler\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: The "CompileXaml " task returned false but did not log an error.

I was able to successfully build a RNW test project a few weeks back to check, but cannot now

Edit - After digging through a few closed issues, moving the folder to my desktop, the project is building, so it seems to be related to the path being too long, even though I have run the dependencies script and enabled long path support. Any workaround to this?

Steps To Reproduce

"npx react-native init xxxx" "npx react-native-windows-init --overwrite" inside project directory "npx react-native run-windows"

Expected Results

Application to build successfully, and blank/template project to run

CLI version

11.3.6

Environment

System:
  OS: Windows 10 10.0.22621
  CPU: "(16) x64 AMD Ryzen 9 5900HS with Radeon Graphics        "
  Memory: 2.93 GB / 15.41 GB
Binaries:
  Node:
    version: 20.5.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm:
    version: 10.0.0
    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: AI-212.5712.43.2112.8512546
  Visual Studio:
    - 17.7.34031.279 (Visual Studio Community 2022)
Languages:
  Java:
    version: 11.0.16.1
    path: C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.4
    wanted: 0.72.4
  react-native-windows:
    installed: 0.72.9
    wanted: 0.72.9
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Target Platform Version

None

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

None

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

No response

Victor0814gui commented 1 year ago

That's great it worked😄! I also had the same issue, but I tested it on react-native-windows@0.72.8 version and it worked perfectly.

jonthysell commented 1 year ago

Edit - After digging through a few closed issues, moving the folder to my desktop, the project is building, so it seems to be related to the path being too long, even though I have run the dependencies script and enabled long path support. Any workaround to this?

It looks like you've worked around this by moving your project into a shorter path?

This may be similar to the MIDL tool's path length limitations (256 regardless of long path support): #10414. Unfortunately the build tools we use codegen some rather long file names which can cause issues if your project's root folder is already long.

chrisglein commented 3 months ago

If I'm reading this right, everyone on the thread is unblocked? Closing.