From 6ef92c88a597e0309b73ebed32c2f30627616a67 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:19:56 +0200 Subject: [PATCH] ci(windows): manually restore NuGet packages before building --- .github/workflows/build.yml | 5 +++ ...ve-windows-cli-npm-0.83.0-2d6aa101ac.patch | 16 ++++++++++ package.json | 1 + packages/app/windows/Win32/ReactApp.vcxproj | 11 ++----- yarn.lock | 31 +++++++++++++++++++ 5 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 .yarn/patches/@react-native-windows-cli-npm-0.83.0-2d6aa101ac.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18261aef8..6839057db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -570,6 +570,11 @@ jobs: - name: Determine whether the Windows app needs to be built id: affected uses: ./.github/actions/affected + - name: Restore NuGet packages + if: ${{ steps.affected.outputs.windows != '' }} + run: | + MSBuild -property:Configuration=${{ matrix.configuration }} -property:Platform=${{ matrix.platform }} -target:Restore + working-directory: packages/example-windows/windows - name: Build id: build if: ${{ steps.affected.outputs.windows != '' }} diff --git a/.yarn/patches/@react-native-windows-cli-npm-0.83.0-2d6aa101ac.patch b/.yarn/patches/@react-native-windows-cli-npm-0.83.0-2d6aa101ac.patch new file mode 100644 index 000000000..af58633a8 --- /dev/null +++ b/.yarn/patches/@react-native-windows-cli-npm-0.83.0-2d6aa101ac.patch @@ -0,0 +1,16 @@ +diff --git a/lib-commonjs/utils/msbuildtools.js b/lib-commonjs/utils/msbuildtools.js +index a9304027f047b9e737a1de6e534aea1812704bd4..9f4ad135b6548506dde09e285afaa33852ee0988 100644 +--- a/lib-commonjs/utils/msbuildtools.js ++++ b/lib-commonjs/utils/msbuildtools.js +@@ -105,10 +105,7 @@ class MSBuildTools { + if (enableParallelBuilds) { + args.push('/maxCpuCount'); + } +- if (target === 'build') { +- args.push('/restore', '/p:RestorePackagesConfig=true'); +- } +- else { ++ if (target !== 'build') { + args.push(`/t:Deploy`); + } + Object.keys(msBuildProps).forEach(key => { diff --git a/package.json b/package.json index 29e6a79d6..b53112ce1 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "@nx/js/picomatch": "^4.0.4", "@nx/workspace/picomatch": "^4.0.4", "@react-native-windows/cli/@xmldom/xmldom": "^0.9.0", + "@react-native-windows/cli@npm:0.83.0": "patch:@react-native-windows/cli@npm%3A0.83.0#~/.yarn/patches/@react-native-windows-cli-npm-0.83.0-2d6aa101ac.patch", "@react-native-windows/telemetry/@xmldom/xmldom": "^0.9.0", "appium/ajv": "~8.18.0", "appium/axios": "^1.15.0", diff --git a/packages/app/windows/Win32/ReactApp.vcxproj b/packages/app/windows/Win32/ReactApp.vcxproj index e0078136f..1a1268a86 100644 --- a/packages/app/windows/Win32/ReactApp.vcxproj +++ b/packages/app/windows/Win32/ReactApp.vcxproj @@ -67,7 +67,7 @@ - + @@ -143,14 +143,7 @@ - + - - - This project references targets in your node_modules\react-native-windows folder. The missing file is {0}. - - - - diff --git a/yarn.lock b/yarn.lock index 1b0fef332..b9d90f7a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3510,6 +3510,37 @@ __metadata: languageName: node linkType: hard +"@react-native-windows/cli@patch:@react-native-windows/cli@npm%3A0.83.0#~/.yarn/patches/@react-native-windows-cli-npm-0.83.0-2d6aa101ac.patch": + version: 0.83.0 + resolution: "@react-native-windows/cli@patch:@react-native-windows/cli@npm%3A0.83.0#~/.yarn/patches/@react-native-windows-cli-npm-0.83.0-2d6aa101ac.patch::version=0.83.0&hash=1cfcc6" + dependencies: + "@react-native-windows/codegen": "npm:0.83.0" + "@react-native-windows/fs": "npm:0.83.0" + "@react-native-windows/package-utils": "npm:0.83.0" + "@react-native-windows/telemetry": "npm:0.83.0" + "@xmldom/xmldom": "npm:^0.7.7" + chalk: "npm:^4.1.0" + cli-spinners: "npm:^2.2.0" + envinfo: "npm:^7.5.0" + execa: "npm:^5.0.0" + find-up: "npm:^4.1.0" + glob: "npm:^7.1.1" + lodash: "npm:^4.17.15" + mustache: "npm:^4.0.1" + ora: "npm:^3.4.0" + prompts: "npm:^2.4.1" + semver: "npm:^7.3.2" + shelljs: "npm:^0.8.4" + username: "npm:^5.1.0" + xml-formatter: "npm:^2.4.0" + xml-parser: "npm:^1.2.1" + xpath: "npm:^0.0.27" + peerDependencies: + react-native: "*" + checksum: 10c0/ce53b656464c47a18e04b06b6eeb3075da3d960f548787e8a44528c96ff334fa17ecc3ccd25160ea7b765aa4c82573f5de4a37ddefe36b709effe0ed43bf8210 + languageName: node + linkType: hard + "@react-native-windows/codegen@npm:0.83.0": version: 0.83.0 resolution: "@react-native-windows/codegen@npm:0.83.0"