Skip to content

Autolinking is picking up project files not meant to be autolinked #8072

Closed
@tido64

Description

@tido64

@react-native-windows/cli is adding a project file that wasn't meant to be autolinked. This was probably introduced in 11a322b.

Correct me if I'm wrong, but it seems like we are assuming that if react-native config populates the windows field, it must be a react-native-windows compatible project. This will break JS-only libraries that have a Windows test app somewhere in the package. As far as I can see, there are two solutions to this, either rename the windows folder to something else, or disable autolinking of the package altogether, i.e.:

// react-native.config.js
module.exports = {
  dependency: {
    platforms: {
      windows: null,
    },
  },
};

Environment

  1. npx react-native --version: 5.0.1
  2. npx react-native info:
    System:
      OS: Windows 10 10.0.19041
      CPU: (4) x64 Intel(R) Core(TM) i5-4690K CPU @ 3.50GHz
      Memory: 7.33 GB / 15.45 GB
    Binaries:
      Node: 14.16.1 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.14.12 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      react: 17.0.2 => 17.0.2
      react-native: ^0.64.2 => 0.64.2
      react-native-windows: canary => 0.0.0-canary.327
    Installed UWP SDKs:
      10.0.18362.0
      10.0.19041.0
    
  • Target Device(s): Desktop
  • Visual Studio Version: 2019

Steps To Reproduce

git clone https://github.com/microsoft/react-native-test-app.git
cd react-native-test-app
yarn set-react-version canary-windows
cd example
yarn
yarn install-windows-test-app --use-nuget
cd windows
nuget restore

Expected Results

nuget restore to succeed. Instead, I'm getting an error The solution file has two projects named "ReactTestApp" because a .vcxproj was added twice. I can work around this error by adding a Dummy.vcxproj to force isRnwDependencyProject to be called, but then I get an exception Found a Windows solution for ReactTestApp but no React Native for Windows native module projects.

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

See "Steps To Reproduce".

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions