Skip to content

Commit 241ba7a

Browse files
authored
Force all in-repo projects to build locally with RestoreForceEvaluate (#14758)
## Description This PR fixes it so every project in the repo, unless explicitly specified, builds locally **with** the nuget lock files and forced evaluation, but ensures external projects build **without** nuget lock files and forced evaluation. This is primarily to fix `e2e-test-app` failing to build locally. ### Type of Change - Bug fix (non-breaking change which fixes an issue) ### Why Fix `e2e-test-app` not building locally with `run-windows`, and prevent our lock file requirements form leaking outside of the repo. ### What The published `Directory.Build.props` file will disable using lock files by default, but the unpublished, in-repo `Directory.Build.props` file will enable using lock files by default. Also, since msbuild from the command line ignores the RestoreForceEvaluate specified anyway, which causes `e2e-test-app` (and any C# app) to always fail when it's turned off (and lock mode is on), we add the prop to the default windows command. ## Screenshots N/A ## Testing Verified `e2e-test-app` builds locally with `run-windows` and within VS 17.14. ## Changelog Should this change be included in the release notes: _yes_ Force all in-repo projects to build locally with RestoreForceEvaluate
1 parent 31c4afb commit 241ba7a

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

.ado/jobs/universal.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,17 @@
269269
displayName: Restore NuGet packages
270270
# Should be kept in sync with UniversalBuild - template: ../templates/msbuild-sln.yml
271271
inputs:
272-
solution: vnext/Microsoft.ReactNative.sln
272+
${{ if eq(matrix.UseFabric, true) }}:
273+
solution: vnext/Microsoft.ReactNative.NewArch.sln
274+
${{ else }}:
275+
solution: vnext/Microsoft.ReactNative.sln
273276
platform: ${{ matrix.BuildPlatform }}
274277
configuration: ${{ matrix.BuildConfiguration }}
275278
msbuildArchitecture: x64
276279
msbuildArguments:
277-
/t:Restore
280+
/restore
281+
/p:RestoreLockedMode=true
282+
/p:RestoreForceEvaluate=true
278283

279284
- task: VSTest@2
280285
displayName: Run Universal Unit Tests (Native)

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ x86/
167167
bld/
168168
[Ll]og/
169169
*.binlog
170+
*.err
171+
*.wrn
170172

171173
# Certificates
172174
*.pfx

Directory.Build.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
<MSBuildProjectExtensionsPath Condition="'$(ProjectName)' != ''">$(RootIntDir)\ProjectExtensions\$(ProjectName)\</MSBuildProjectExtensionsPath>
3030
<MSBuildProjectExtensionsPath Condition="'$(ProjectName)' == ''">$(RootIntDir)\ProjectExtensions\$(MSBuildProjectName)\</MSBuildProjectExtensionsPath>
3131
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
32+
<RestoreLockedMode Condition="'$(RestoreLockedMode)' == ''">true</RestoreLockedMode>
33+
<RestorePackagesWithLockFile Condition="'$(RestorePackagesWithLockFile)' == ''">true</RestorePackagesWithLockFile>
34+
<RestoreForceEvaluate Condition="'$(RestoreForceEvaluate)' == ''">true</RestoreForceEvaluate>
3235
</PropertyGroup>
3336

3437
<!-- User overrides -->
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Force all in-repo projects to build locally with RestoreForceEvaluate",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/e2e-test-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"lint": "rnw-scripts lint",
88
"lint:fix": "rnw-scripts lint:fix",
99
"watch": "rnw-scripts watch",
10-
"windows": "npx @react-native-community/cli run-windows",
10+
"windows": "npx @react-native-community/cli run-windows --msbuildprops RestoreForceEvaluate=true",
1111
"e2etest": "jest",
1212
"e2etest:updateSnapshots": "jest -u",
1313
"e2etest:debug": "jest --config ./jest.debug.config.js"

vnext/Directory.Build.props

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,13 @@
7474

7575
<IntermediateOutputPath Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(IntDir)</IntermediateOutputPath>
7676
<OutputPath Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(OutDir)</OutputPath>
77+
</PropertyGroup>
7778

78-
<RestorePackagesWithLockFile Condition="'$(RestorePackagesWithLockFile)' == ''">true</RestorePackagesWithLockFile>
79+
<PropertyGroup Condition="'$(BuildingInRnwRepo)' != 'true'">
80+
<!-- Consumers of RNW outside of the repo don't need lock files unless they ask for it -->
81+
<RestoreLockedMode Condition="'$(RestoreLockedMode)' == ''">false</RestoreLockedMode>
82+
<RestorePackagesWithLockFile Condition="'$(RestorePackagesWithLockFile)' == ''">false</RestorePackagesWithLockFile>
7983
<RestoreForceEvaluate Condition="'$(RestoreForceEvaluate)' == ''">false</RestoreForceEvaluate>
80-
8184
</PropertyGroup>
8285

8386
<PropertyGroup Label="NuGet" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'">

0 commit comments

Comments
 (0)