microsoft / microsoft/react-native-windows
Specifying minimum VS version with `VisualStudioVersion` environment variable can break `run-windows`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 17.3k
- Forks
- 1.2k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 33
Description
Problem Description
We allow users to specify the minimum version of VS to use by setting the VisualStudioVersion environment variable. npx react-native run-windows will then read that value and use it to find the desired VS install.
However, many built-in VS targets use this variable in calculating paths, so setting it can actually break the build.
Example, setting to 17.7 (the current preview) we get:
Build failed with message 5:8>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(2688,3): error MSB4019: The imported project "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\WindowsXaml\v17.7\Microsoft.Windows.UI.Xaml.Cpp.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\WindowsXaml\v17.7\Microsoft.Windows.UI.Xaml.Cpp.targets" is correct, and that the file exists on disk. [E:\code\demo\node_modules\react-native-windows\Folly\Folly.vcxproj]. Check your build configuration.
The path has the 17.7 string we specified, but it should be 17.0. It looks like the VisualStudioVersion environment variable must be just the major version.
Steps To Reproduce
npx react-native init demo --template react-native@^0.71.0cd demonpx react-native-windows-init --overwriteset VisualStudioVersion=17.7yarn windows --logging
Expected Results
This should build, but instead we get an error.
CLI version
12.0.0-alpha.3
Environment
info Fetching system and libraries information...
System:
OS: Windows 10 10.0.25336
CPU: "(24) x64 AMD Ryzen Threadripper PRO 3945WX 12-Cores "
Memory: 53.66 GB / 63.86 GB
Binaries:
Node:
version: 16.19.1
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.19
path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm:
version: 9.6.2
path: 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:
- 16.11.33529.622 (Visual Studio Enterprise 2019)
- 17.6.33723.286 (Visual Studio Enterprise 2022)
- 17.7.33711.374 (Visual Studio Enterprise 2022)
Languages:
Java: Not Found
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react: Not Found
react-native: Not Found
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Target Platform Version
10.0.19041
Target Device(s)
Desktop
Visual Studio Version
Visual Studio 2022
Build Configuration
Debug
Snack, code example, screenshot, or link to a repository
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with npx react-native run-windows after setting VisualStudioVersion=17.7, following the listed initialization steps. Trace the run-windows entry point to see how that value is used for Visual Studio selection and passed into the build; done means the same setup builds successfully without generating the incorrect v17.7 XAML target path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, react-native
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100