Skip to content

Commit 0f9e46c

Browse files
committed
## Description
This PR fixes NuGet lock files so they're more correct/compliant. ### Type of Change - Bug fix (non-breaking change which fixes an issue) ### Why We recently updated to WinAppSDK 1.7 and have made other changes to the flavors we build (with different dependencies) so our lock files were out of date / constantly overriding one another. ### What This PR fixes NuGet lock files so they're more correct/compliant. This includes: 1. Updating the `NuGetRestoreForceEvaluateAllSolutions.ps1` script to completely fix the lock files 2. Ensuring every project has a proper `packages.lock.json` file for its default configuration 3. Ensuring projects that are built old AND new arch also have a separate `newarch` lock file 4. Ensuring projects that are build with/without experimental WinUI3 also have a separate `experimentalwinui3` lock file 5. Causing an (optional) CI build error if the lock files change during the build (they shouldn't) with message to re-run the script 6. Removed all unnecessary `packages.config` files which confuse NuGet restoration ## Screenshots N/A ## Testing Verified no complaints about changed lock files after builds in the pipeline. ## Changelog Should this change be included in the release notes: _no_
1 parent cb69407 commit 0f9e46c

File tree

75 files changed

+4284
-385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+4284
-385
lines changed

.ado/jobs/e2e-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
buildPlatform: ${{ matrix.BuildPlatform }}
8585
buildLogDirectory: $(BuildLogDirectory)
8686
workingDirectory: packages/e2e-test-app
87+
errorOnNuGetLockChanges: false # Sometimes the content hashes of NuGet packages are wrong on VMs, workaround for later .NET versions don't work for UWP C#.
8788

8889
- script: |
8990
echo ##vso[task.setvariable variable=StartedTests]true

.ado/jobs/playground.yml

-10
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,6 @@ jobs:
130130
parameters:
131131
workingDir: packages\playground\windows
132132

133-
# NuGet ignores packages.config if it detects <PackageReference>.
134-
# Use restore packages.config directly to keep compabitility with ReactNativePicker.
135-
- pwsh: |
136-
Get-ChildItem -Recurse -Path packages.config |`
137-
Foreach-Object {`
138-
NuGet.exe Restore -PackagesDirectory packages $_`
139-
}
140-
workingDirectory: packages/playground/windows
141-
displayName: Restore packages.config items
142-
143133
- template: ../templates/msbuild-sln.yml
144134
parameters:
145135
solutionDir: packages/playground/windows

.ado/jobs/sample-apps.yml

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ jobs:
8383
deployOption: ${{ matrix.DeployOption }}
8484
buildLogDirectory: ${{ variables['BuildLogDirectory'] }}
8585
workingDirectory: packages/sample-apps
86+
errorOnNuGetLockChanges: false # Sometimes the content hashes of NuGet packages are wrong on VMs, workaround for later .NET versions don't work for UWP C#.
8687

8788
- script: yarn bundle-cpp --verbose
8889
displayName: Create SampleApp bundle
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
parameters:
2+
- name: errorOnNuGetLockChanges
3+
type: boolean
4+
default: true
5+
6+
steps:
7+
- powershell: |
8+
& git add */packages*.lock.json
9+
$changed = git status --porcelain=v1 */packages*.lock.json
10+
if ($changed -ne $null) {
11+
Write-Host "Detected NuGet lock file changes during the build:"
12+
Write-Host Files changed:`n([string]::Join("`n", $changed))
13+
$diff = git diff --cached -- */packages*.lock.json
14+
Write-Host Diff:`n([string]::Join("`n", $diff))
15+
$msg = "Detected NuGet lock file changes during the build. Run vnext/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 locally in a VS Dev PowerShell to update lock files, then submit the changes."
16+
if ("${{ parameters.errorOnNuGetLockChanges }}" -eq "True") {
17+
Write-Host "##vso[task.logissue type=error]Detected NuGet lock file changes during the build. Run vnext/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 locally in a VS Dev PowerShell to update lock files, then submit the changes."
18+
[Environment]::Exit(-1)
19+
}
20+
}
21+
displayName: Detect NuGet lock file changes during build
22+
condition: succeededOrFailed()

.ado/templates/msbuild-sln.yml

+1-12
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,7 @@ steps:
5555
$(MsBuildWarnAsErrorArgument)
5656
${{parameters.msbuildArguments}}
5757

58-
- powershell: |
59-
& git add */packages*.lock.json
60-
$changed = git status --porcelain=v1 */packages*.lock.json
61-
if ($changed -ne $null) {
62-
Write-Host "##[warning] Detected packages.lock.json changes. See full log for details."
63-
Write-Host Files changed:`n([string]::Join("`n", $changed))
64-
$diff = git diff --cached -- */packages*.lock.json
65-
Write-Host Diff:`n([string]::Join("`n", $diff))
66-
Write-Host "Run vnext/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 to update lock files locally."
67-
}
68-
displayName: Detect packages.lock.json changes during build
69-
condition: succeededOrFailed()
58+
- template: detect-nuget-lockfile-changes.yml
7059

7160
- template: upload-build-logs.yml
7261
parameters:

.ado/templates/run-windows-with-certificates.yml

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ parameters:
2626
- name: restoreForceEvaluate
2727
type: boolean
2828
default: true
29+
- name: errorOnNuGetLockChanges
30+
type: boolean
31+
default : true
2932
- name: moreMSBuildProps
3033
type: string
3134
default: ''
@@ -77,3 +80,8 @@ steps:
7780
workingDirectory: ${{ parameters.workingDirectory }}
7881
7982
- template: ../templates/cleanup-certificate.yml
83+
84+
- ${{ if eq(parameters.restoreLockedMode, 'true') }}:
85+
- template: detect-nuget-lockfile-changes.yml
86+
parameters:
87+
errorOnNuGetLockChanges: ${{ parameters.errorOnNuGetLockChanges }}

Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<PropertyGroup Label="NuGet">
2929
<MSBuildProjectExtensionsPath Condition="'$(ProjectName)' != ''">$(RootIntDir)\ProjectExtensions\$(ProjectName)\</MSBuildProjectExtensionsPath>
3030
<MSBuildProjectExtensionsPath Condition="'$(ProjectName)' == ''">$(RootIntDir)\ProjectExtensions\$(MSBuildProjectName)\</MSBuildProjectExtensionsPath>
31+
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
3132
</PropertyGroup>
3233

3334
<!-- User overrides -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix NuGet lock files",
4+
"packageName": "@react-native-windows/automation-channel",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Fix NuGet lock files",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{
2+
"version": 1,
3+
"dependencies": {
4+
"native,Version=v0.0": {
5+
"Microsoft.UI.Xaml": {
6+
"type": "Direct",
7+
"requested": "[2.8.0, )",
8+
"resolved": "2.8.0",
9+
"contentHash": "vxdHxTr63s5KVtNddMFpgvjBjUH50z7seq/5jLWmmSuf8poxg+sXrywkofUdE8ZstbpO9y3FL/IXXUcPYbeesA==",
10+
"dependencies": {
11+
"Microsoft.Web.WebView2": "1.0.1264.42"
12+
}
13+
},
14+
"Microsoft.Windows.CppWinRT": {
15+
"type": "Direct",
16+
"requested": "[2.0.230706.1, )",
17+
"resolved": "2.0.230706.1",
18+
"contentHash": "l0D7oCw/5X+xIKHqZTi62TtV+1qeSz7KVluNFdrJ9hXsst4ghvqQ/Yhura7JqRdZWBXAuDS0G0KwALptdoxweQ=="
19+
},
20+
"boost": {
21+
"type": "Transitive",
22+
"resolved": "1.83.0",
23+
"contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ=="
24+
},
25+
"Microsoft.Build.Tasks.Git": {
26+
"type": "Transitive",
27+
"resolved": "1.1.1",
28+
"contentHash": "AT3HlgTjsqHnWpBHSNeR0KxbLZD7bztlZVj7I8vgeYG9SYqbeFGh0TM/KVtC6fg53nrWHl3VfZFvb5BiQFcY6Q=="
29+
},
30+
"Microsoft.JavaScript.Hermes": {
31+
"type": "Transitive",
32+
"resolved": "0.1.23",
33+
"contentHash": "cA9t1GjY4Yo0JD1AfA//e1lOwk48hLANfuX6GXrikmEBNZVr2TIX5ONJt5tqCnpZyLz6xGiPDgTfFNKbSfb21g=="
34+
},
35+
"Microsoft.SourceLink.Common": {
36+
"type": "Transitive",
37+
"resolved": "1.1.1",
38+
"contentHash": "WMcGpWKrmJmzrNeuaEb23bEMnbtR/vLmvZtkAP5qWu7vQsY59GqfRJd65sFpBszbd2k/bQ8cs8eWawQKAabkVg=="
39+
},
40+
"Microsoft.SourceLink.GitHub": {
41+
"type": "Transitive",
42+
"resolved": "1.1.1",
43+
"contentHash": "IaJGnOv/M7UQjRJks7B6p7pbPnOwisYGOIzqCz5ilGFTApZ3ktOR+6zJ12ZRPInulBmdAf1SrGdDG2MU8g6XTw==",
44+
"dependencies": {
45+
"Microsoft.Build.Tasks.Git": "1.1.1",
46+
"Microsoft.SourceLink.Common": "1.1.1"
47+
}
48+
},
49+
"Microsoft.Web.WebView2": {
50+
"type": "Transitive",
51+
"resolved": "1.0.1264.42",
52+
"contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA=="
53+
},
54+
"common": {
55+
"type": "Project",
56+
"dependencies": {
57+
"boost": "[1.83.0, )"
58+
}
59+
},
60+
"fmt": {
61+
"type": "Project"
62+
},
63+
"folly": {
64+
"type": "Project",
65+
"dependencies": {
66+
"boost": "[1.83.0, )",
67+
"fmt": "[1.0.0, )"
68+
}
69+
},
70+
"microsoft.reactnative": {
71+
"type": "Project",
72+
"dependencies": {
73+
"Common": "[1.0.0, )",
74+
"Folly": "[1.0.0, )",
75+
"Microsoft.JavaScript.Hermes": "[0.1.23, )",
76+
"Microsoft.SourceLink.GitHub": "[1.1.1, )",
77+
"Microsoft.UI.Xaml": "[2.8.0, )",
78+
"ReactCommon": "[1.0.0, )",
79+
"boost": "[1.83.0, )"
80+
}
81+
},
82+
"reactcommon": {
83+
"type": "Project",
84+
"dependencies": {
85+
"Folly": "[1.0.0, )",
86+
"boost": "[1.83.0, )"
87+
}
88+
}
89+
},
90+
"native,Version=v0.0/win10-arm": {
91+
"Microsoft.Web.WebView2": {
92+
"type": "Transitive",
93+
"resolved": "1.0.1264.42",
94+
"contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA=="
95+
}
96+
},
97+
"native,Version=v0.0/win10-arm-aot": {
98+
"Microsoft.Web.WebView2": {
99+
"type": "Transitive",
100+
"resolved": "1.0.1264.42",
101+
"contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA=="
102+
}
103+
},
104+
"native,Version=v0.0/win10-arm64-aot": {
105+
"Microsoft.Web.WebView2": {
106+
"type": "Transitive",
107+
"resolved": "1.0.1264.42",
108+
"contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA=="
109+
}
110+
},
111+
"native,Version=v0.0/win10-x64": {
112+
"Microsoft.Web.WebView2": {
113+
"type": "Transitive",
114+
"resolved": "1.0.1264.42",
115+
"contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA=="
116+
}
117+
},
118+
"native,Version=v0.0/win10-x64-aot": {
119+
"Microsoft.Web.WebView2": {
120+
"type": "Transitive",
121+
"resolved": "1.0.1264.42",
122+
"contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA=="
123+
}
124+
},
125+
"native,Version=v0.0/win10-x86": {
126+
"Microsoft.Web.WebView2": {
127+
"type": "Transitive",
128+
"resolved": "1.0.1264.42",
129+
"contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA=="
130+
}
131+
},
132+
"native,Version=v0.0/win10-x86-aot": {
133+
"Microsoft.Web.WebView2": {
134+
"type": "Transitive",
135+
"resolved": "1.0.1264.42",
136+
"contentHash": "7OBUTkzQ5VI/3gb0ufi5U4zjuCowAJwQg2li0zXXzqkM+S1kmOlivTy1R4jAW+gY5Vyg510M+qMAESCQUjrfgA=="
137+
}
138+
}
139+
}
140+
}

packages/@react-native-windows/automation-channel/windows/AutomationChannel/packages.config

-4
This file was deleted.

0 commit comments

Comments
 (0)