Open sivakusayan opened 1 year ago
In case people are wondering why we might want to force single process builds, we're getting some errors from MSBuild processes tripping each other up by trying to get locks on the same file, resulting in build failures.
There might be a simpler solution for what we need (I'm not too familiar with the MSBuild ecosystem) but for now we're probably just going to roll with a naked msbuild
command instead of using the react-native-windows
wrapper around msbuild
.
Should be a supported arg, not sure why it's not making it through to msbuild. Was added in this PR: https://github.com/microsoft/react-native-windows/pull/5784
For people who need a workaround, we used patch-package
to get around this with this patch:
diff --git a/node_modules/@react-native-windows/cli/lib-commonjs/runWindows/utils/msbuildtools.js b/node_modules/@react-native-windows/cli/lib-commonjs/runWindows/utils/msbuildtools.js
index 61a29f8..0fa023a 100644
--- a/node_modules/@react-native-windows/cli/lib-commonjs/runWindows/utils/msbuildtools.js
+++ b/node_modules/@react-native-windows/cli/lib-commonjs/runWindows/utils/msbuildtools.js
@@ -102,7 +102,7 @@ class MSBuildTools {
// doesn't lead to dramatic performance gains (See #4739). Only enable
// parallel builds on machines with >16GB of memory to avoid OOM errors
const highMemory = (0, os_1.totalmem)() > 16 * 1024 * 1024 * 1024;
- const enableParallelBuilds = singleproc === false || highMemory;
+ const enableParallelBuilds = singleproc !== undefined ? !singleproc : highMemory;
if (enableParallelBuilds) {
args.push('/maxCpuCount');
}
Using git-blame
, I think this is a regression from https://github.com/microsoft/react-native-windows/pull/5796.
Problem Description
As noted in this code (thanks to @ryfow for the investigation), if a computer has more than 16GB of memory and the
--singleproc
flag is passed, we will not respect the--singleproc
flag because of the OR check.Steps To Reproduce
/maxCpuCount
is logged when we log the arguments passed to MSBuild.Expected Results
I expect that
/maxCpuCount
is not passed to MSBuild when the--singleproc
flag is passed.CLI version
11.3.7
Environment
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