react-native-windows-samples icon indicating copy to clipboard operation
react-native-windows-samples copied to clipboard

NativeModuleSample cppwinrt fails to build: Cannot open include file: 'winrt/impl/Windows.Devices.Bluetooth.GenericAttributeProfile.1.h'

Open chrisglein opened this issue 2 years ago • 7 comments
trafficstars

Sample

NativeModuleSample

Problem Description

NativeModuleSample cppwinrt fails to build:

Cannot open include file: 'winrt/impl/Windows.Devices.Bluetooth.GenericAttributeProfile.1.h'

Time Elapsed 00:00:00.55
√ Restoring NuGet packages
 i Autolink step is skipped
 √ Found Solution: C:\Users\redacted\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt\windows\NativeModuleSample.sln
 i Build configuration: Debug
 i Build platform: x64
 × Building Solution: C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\XamlCompiler\Microsoft.Windows.UI.X...
 × Build failed with message 7:7>C:\Users\redacted\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt\node_modules\react-native-windows\Microsoft.ReactNative\build\x64\Debug\Microsoft.ReactNative\Generated Files\winrt\impl\Windows.ApplicationModel.Background.2.h(8,10): fatal  error C1083: Cannot open include file: 'winrt/impl/Windows.Devices.Bluetooth.GenericAttributeProfile.1.h': No such file or directory (compiling source file C:\Users\redacted\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt\node_modules\react-native-windows\Shared\Executors\WebSocketJSExecutor.cpp) [C:\Users\redacted\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]. Check your build configuration.
Command failed. Re-run the command with --logging for more information.

Steps To Reproduce

(See readme)

  1. Clone repo
  2. cd samples\NativeModuleSample\cppwinrt
  3. yarn
  4. npx react-native run-windows --no-deploy --no-launch --no-packager --no-autolink --proj "NativeModuleSample\NativeModuleSample.vsproj"

Expected Results

follow instructions in readme, get build

CLI version

10.0.0

Environment

info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.23447
    CPU: (24) x64 AMD Ryzen Threadripper PRO 3945WX 12-Cores
    Memory: 40.40 GB / 63.86 GB
  Binaries:
    Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 9.4.1 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      AllowAllTrustedApps: Enabled
      Versions: 10.0.18362.0, 10.0.19041.0, 10.0.22000.0, 10.0.22621.0
  IDEs:
    Android Studio: Not Found
    Visual Studio: 17.5.33530.505 (Visual Studio Community 2022), 16.11.33529.622 (Visual Studio Community 2019)
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.0 => 0.71.0
    react-native-windows: 0.71.0 => 0.71.0
  npmGlobalPackages:
    *react-native*: Not Found

Target Platform Version

None

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

Debug

chrisglein avatar May 01 '23 18:05 chrisglein

Does this repro without passing --proj? Where do we specify to do that? What happens if you just run npx react-native run-windows --logging --no-packager --no-launch --no-autolink --no-deploy --arch x64 which we do in CI?

jonthysell avatar May 01 '23 20:05 jonthysell

If I run npx react-native run-windows --logging --no-packager --no-launch --no-autolink --no-deploy --arch x64 locally everything builds fine except I get an (ignorable) error: No app project file found, please specify in react-native.config. Optionally, use --proj {projFile}..

If I add --proj, i.e. npx react-native run-windows --logging --no-packager --no-launch --no-autolink --no-deploy --arch x64 --proj windows\NativeModuleSample\NativeModuleSample.vcxproj it builds perfectly.

npx react-native info:

info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.25352
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Memory: 7.84 GB / 15.84 GB
  Binaries:
    Node: 16.18.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      AllowAllTrustedApps: Enabled
      Versions: 10.0.16299.0, 10.0.18362.0, 10.0.19041.0, 10.0.22000.0, 10.0.22621.0
  IDEs:
    Android Studio: Not Found
    Visual Studio: 16.11.33529.622 (Visual Studio Enterprise 2019), 17.5.33530.505 (Visual Studio Enterprise 2022)
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.0 => 0.71.0
    react-native-windows: 0.71.0 => 0.71.0
  npmGlobalPackages:
    *react-native*: Not Found

jonthysell avatar May 01 '23 21:05 jonthysell

What happens if you just run npx react-native run-windows --logging --no-packager --no-launch --no-autolink --no-deploy --arch x64 which we do in CI?

C:\Users\REDACTED\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt> npx react-native run-windows --logging --no-packager --no-launch --no-autolink --no-deploy --arch x64

× Building Solution × Build failed with message 7:7>C:\Users\REDACTED\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt\node_modules\react-native-windows\Microsoft.ReactNative\build\x64\Debug\Microsoft.ReactNative\Generated Files\winrt\impl\Windows.ApplicationModel.Background.2.h(8,10): fatal error C1083: Cannot open include file: 'winrt/impl/Windows.Devices.Bluetooth.GenericAttributeProfile.1.h': No such file or directory (compiling source file C:\Users\REDACTED\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt\node_modules\react-native-windows\Shared\PackagerConnection.cpp) [C:\Users\REDACTED\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]. Check your build configuration. × No app project file found, please specify in react-native.config. Optionally, use --proj {projFile}. Command failed with error MSBuildError: 7:7>C:\Users\REDACTED\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt\node_modules\react-native-windows\Microsoft.ReactNative\build\x64\Debug\Microsoft.ReactNative\Generated Files\winrt\impl\Windows.ApplicationModel.Background.2.h(8,10): fatal error C1083: Cannot open include file: 'winrt/impl/Windows.Devices.Bluetooth.GenericAttributeProfile.1.h': No such file or directory (compiling source file C:\Users\REDACTED\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt\node_modules\react-native-windows\Shared\PackagerConnection.cpp) [C:\Users\REDACTED\Source\react-native-windows-samples\samples\NativeModuleSample\cppwinrt\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]

chrisglein avatar May 01 '23 23:05 chrisglein

Not sure if this is helpful but it also runs fine on my machine so possibly a missing dependency? This issue https://github.com/microsoft/react-native-windows-samples/issues/686 had a similar error message but had a workaround

TatianaKapos avatar May 04 '23 17:05 TatianaKapos

At a bare minimum we need to update the readme. I'm going to take another pass with cleaned build output and see if this repros.

UPDATE: Does still repro. And isn't for some other folks. Is there some unspoken dependency here?

chrisglein avatar May 04 '23 18:05 chrisglein

Meet this problem too ... So,how to resolve it?

Hakunata avatar Jun 14 '23 16:06 Hakunata

Has this issue been resolved?

treadways avatar Jul 13 '23 20:07 treadways