microsoft / react-native-windows

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

Generator Will Create an Invalid Solution For Monorepo Projects #5933

Open NickGerleman opened 4 years ago

NickGerleman commented 4 years ago

MyApp.sln hard-codes the path to node_modules\react-native-windows. This path is often not correct, such as when used in monorepos. In this case, the solution will not correctly load.

    GlobalSection(SharedMSBuildProjectFiles) = preSolution
        ..\node_modules\react-native-windows\JSI\Shared\JSI.Shared.vcxitems*{0cc28589-39e4-4288-b162-97b959f8b843}*SharedItemsImports = 9
        ..\node_modules\react-native-windows\Shared\Shared.vcxitems*{2049dbe9-8d13-42c9-ae4b-413ae38fffd0}*SharedItemsImports = 9
        ..\node_modules\react-native-windows\Mso\Mso.vcxitems*{84e05bfa-cbaf-4f0d-bfb6-4ce85742a57e}*SharedItemsImports = 9
        ..\node_modules\react-native-windows\JSI\Shared\JSI.Shared.vcxitems*{a62d504a-16b8-41d2-9f19-e2e86019e5e4}*SharedItemsImports = 4
        ..\node_modules\react-native-windows\Chakra\Chakra.vcxitems*{c38970c0-5fbf-4d69-90d8-cbac225ae895}*SharedItemsImports = 9
        ..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{da8b35b3-da00-4b02-bde6-6a397b3fd46b}*SharedItemsImports = 9
        ..\node_modules\react-native-windows\include\Include.vcxitems*{ef074ba1-2d54-4d49-a28e-5e040b47cd2e}*SharedItemsImports = 9
        ..\node_modules\react-native-windows\Chakra\Chakra.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
        ..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
        ..\node_modules\react-native-windows\Mso\Mso.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
        ..\node_modules\react-native-windows\Shared\Shared.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
    EndGlobalSection
chrisglein commented 4 years ago

Project generator would need to navigate the yarn lookup to find wherever it actually is. Think the result would still be static (can't have the SLN file do the dynamic lookup).

ugrylmz commented 4 years ago

My monorepo project structure is: myproject/ | package.json (main monorepo config) includes "workspaces": { "packages": [ "packages/*" ], "nohoist": [ "/react-native-windows", "/react-native-windows/**" ] }, /packages /mobile | package.json (monorepo config(dirname)) "react-native-windows": "^0.63.0-0","react-native": "0.63.2", "shared": "0.0.1", | metro.config | android | ios | windows

/shared

C:\rnWindows\packages\mobile\node_modules\react-native-windows\ReactCommon\ReactCommon.vcxproj : error  : The project file could not be loaded. Could not find a part of the path 'C:\rnWindows\packages\mobile\node_modules\react-native-windows\ReactCommon\ReactCommon.vcxproj'.  C:\rnWindows\packages\mobile\node_modules\react-native-windows\ReactCommon\ReactCommon.vcxproj

C:\rnWindows\packages\mobile\node_modules\react-native-windows\Chakra\Chakra.vcxitems : error  : Project "C:\rnWindows\packages\mobile\node_modules\react-native-windows\Chakra\Chakra.vcxitems" could not be found.

C:\rnWindows\packages\mobile\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj : error  : The project file could not be loaded. Could not find a part of the path 'C:\rnWindows\packages\mobile\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj'.  C:\rnWindows\packages\mobile\node_modules\react-native-windows\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj

C:\rnWindows\packages\mobile\node_modules\react-native-windows\JSI\Shared\JSI.Shared.vcxitems : error  : Project "C:\rnWindows\packages\mobile\node_modules\react-native-windows\JSI\Shared\JSI.Shared.vcxitems" could not be found.

C:\rnWindows\packages\mobile\node_modules\react-native-windows\JSI\Universal\JSI.Universal.vcxproj : error  : The project file could not be loaded. Could not find a part of the path 'C:\rnWindows\packages\mobile\node_modules\react-native-windows\JSI\Universal\JSI.Universal.vcxproj'.  C:\rnWindows\packages\mobile\node_modules\react-native-windows\JSI\Universal\JSI.Universal.vcxproj

C:\rnWindows\packages\mobile\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems : error  : Project "C:\rnWindows\packages\mobile\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems" could not be found.

C:\rnWindows\packages\mobile\node_modules\react-native-windows\Common\Common.vcxproj : error  : The project file could not be loaded. Could not find a part of the path 'C:\rnWindows\packages\mobile\node_modules\react-native-windows\Common\Common.vcxproj'.  C:\rnWindows\packages\mobile\node_modules\react-native-windows\Common\Common.vcxproj

C:\rnWindows\packages\mobile\node_modules\react-native-windows\Folly\Folly.vcxproj : error  : The project file could not be loaded. Could not find a part of the path 'C:\rnWindows\packages\mobile\node_modules\react-native-windows\Folly\Folly.vcxproj'.  C:\rnWindows\packages\mobile\node_modules\react-native-windows\Folly\Folly.vcxproj

C:\rnWindows\packages\mobile\node_modules\react-native-windows\Shared\Shared.vcxitems : error  : Project "C:\rnWindows\packages\mobile\node_modules\react-native-windows\Shared\Shared.vcxitems" could not be found.

C:\rnWindows\packages\mobile\node_modules\react-native-windows\Mso\Mso.vcxitems : error  : Project "C:\rnWindows\packages\mobile\node_modules\react-native-windows\Mso\Mso.vcxitems" could not be found.

C:\rnWindows\packages\mobile\node_modules\react-native-windows\include\Include.vcxitems : error  : Project "C:\rnWindows\packages\mobile\node_modules\react-native-windows\include\Include.vcxitems" could not be found.

C:\rnWindows\packages\mobile\node_modules\react-native-windows\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.csproj : error  : The project file could not be loaded. Could not find a part of the path 'C:\rnWindows\packages\mobile\node_modules\react-native-windows\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.csproj'.  C:\rnWindows\packages\mobile\node_modules\react-native-windows\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.csproj

C:\rnWindows\packages\mobile\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj : error  : The project file cannot be found.

error : Designtime build failed for project 'C:\rnWindows\packages\mobile\windows\mobile\mobile.vcxproj' configuration 'Debug|ARM'. IntelliSense might be unavailable.
    Set environment variable TRACEDESIGNTIME = true and restart Visual Studio to investigate.

npx react-native --version: 4.13.0
npx react-native run-windows --info:
 System:
    OS: Windows 10 10.0.17763
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    Memory: 2.07 GB / 15.87 GB
  Binaries:
    Node: 12.2.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    react: 16.13.1 => 16.13.1
    react-native: 0.63.2 => 0.63.2
    react-native-windows: ^0.63.0-0 => 0.63.3
  Installed UWP SDKs:
    10.0.14393.0
    10.0.17763.0
    10.0.18362.0
react-native-cli: 2.0.1
react-native: 0.63.2
npm ls rnpm-plugin-windows: mobile@0.0.1 C:\repos\....\......UI\packages\mobile
yarn --version : 1.22.4
node -v : v12.2.0
npm -v: 6.9.0
zzorba commented 2 months ago

Does anyone have a workaround for this? I'd love to use RNW but our project is in a monorepo (with the main 'binary' under /apps/expo), and the generated *.sln is still looking for files one level up instead of at the root of the repository.

acoates-ms commented 2 months ago

You can certainly manually edit the sln file to provide the appropriate paths to the project files.