-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Error: NU1403 Package content hash validation failed for NETStandard.Library.2.0.3. The package is different than the last restore. #11610
Comments
Hey @Kurt-von-Laven, As mentioned in the other issue, the problem here is that there's probably a package that was somehow preinstalled on your machine that doesn't match the same package that would've been installed if say you got the package from nuget.org. So there's actually a discrepancy, and our first step is to understand how the discrepancy happened (usually by some preinstalled packages), and then once we know how it happened, we can proceed fixing or correcting whatever it may be that caused this difference. Can you please find the obj folder of the project you're having issues with and open the assets file. In there, you'll find a prop called On my machine it can be something like: "packageFolders": {
"C:\\Users\\Roki2\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {},
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\": {},
"C:\\Program Files (x86)\\Microsoft SDKs\\UWPNuGetPackages\\": {}
}, Then please go into each one of those folders and find the netstandard.library equivalent folder, and please upload the: Please note that the ordering in the packageFolders object matters, so please make sure you preserve that when you paste that information. Thanks! |
Thank you, @nkolev92! This has been super illuminating, and the results are as I imagine you expected. Here is the relevant excerpt from "packageFolders": {
"%USERPROFILE%\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {},
"C:\\Program Files (x86)\\Microsoft SDKs\\UWPNuGetPackages\\": {}
}, The only copy of these files was in {
"version": 1,
"contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ=="
} The contents of I created a |
Turns out the UWPNuGetPackages source is getting added in a way that it's not easy to disable right now. It's being set through RestoreAdditionalProjectFallbackFolders, and it's being set in
or the equivalent on your machine, and it's bringing a version of the library that has incorrect metadata., which should in reality be: Unfortunately given that it's in the targets, it needs to be done after that. Can you try creating a Directory.Build.targets with the following content? <Project>
<PropertyGroup>
<RestoreAdditionalProjectFallbackFolders></RestoreAdditionalProjectFallbackFolders>
</PropertyGroup>
</Project> If that works, I'll try to see if the fallback folder can be fixed up in a VS update. |
What a great find! That forced NuGet to pull down all of the UWP libraries from nuget.org. As desired, within {
"version": 2,
"contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"source": "https://api.nuget.org/v3/index.json"
} However, Evidently NuGet looks at the former, because it no longer complains about Predictably, the pertinent {
"version": 2,
"contentHash": "ok+RPAtESz/9MUXeIEz6Lv5XAGQsaNmEYXMsgVALj4D7kqC8gveKWXWXbufLySR2fWrwZf8smyN5RmHu0e4BHA==",
"source": "https://api.nuget.org/v3/index.json"
} However, |
What does the .nupkg.metadata contain? |
Good to know. The exact contents of the |
You need to run restore with /p:RestoreForceEvaluate="true" to update the lock file. Can you try that? |
Updating the lock file of course succeeds by modifying the expected hash of |
It's the fallback folder that's been providing the hash incorrectly. |
Thank you for confirming! Should I open a separate issue to get the hashes of both of these packages corrected in the fallback folder? (If so, where?) |
Can you please file an issue at developercommunity about fixing the UWPNuGetPackages fallback folder. I'll work on finding the best owner for that. |
@Kurt-von-Laven |
Apologies for the delay; just got back from a trip. Yes, I am closing this issue in favor of https://developercommunity.visualstudio.com/t/NETStandardLibrary203-Ships-With-Wro/1688568 and https://developercommunity.visualstudio.com/t/MicrosoftNETCorePlatforms210-Ships/1688567. Thank you for helping us get unblocked so quickly! |
Just wanted to make a note that I had a similar problem with FSharp.Core 6.0.5 today on the build server, with exactly this problem - - mismatching hashes. It looks like .NET SDK 6.0.400 was dropped yesterday, which is exactly when it started failing. Forcing the build server back to 6.0.303 fixed the issue, so presumably, the hashing algorithm is behaving differently. |
Seconding this. Rolling back to FSharp.Core 6.0.3 worked for me. |
NuGet Product Used
MSBuild.exe
Product Version
MSBuild 17.1.0+ae57d105c, Visual Studio 17.1.0
Worked before?
MSBuild 17.0.6, Visual Studio 17.0.6
Impact
I'm unable to use this version
Repro Steps & Context
To clarify, the impact of this issue is that I can not build our UWP app on any version of any tool without removing the lock file, which is prohibitively risky since it may be catching and preventing a live attack on the Microsoft ecosystem.
Repro steps:
NETStandard.Library.2.0.3
:"st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A=="
. This can be achieved by introducing a direct dependency on Microsoft.NETCore.UniversalWindowsPlatform.6.2.13 and adding the following to your.csproj
:You will probably then need to modify the hash in the lock file (
packages.lock.json
) to the value provided above.Expected result:
The project builds without errors.
Actual result:
The project builds successfully, but reports error NU1403 because of a lock file hash mismatch in
NETStandard.Library.2.0.3
. The error was first observed on February 22nd, 2022 at 18:33 UTC. The same project built successfully without reporting any errors prior to this, and the error has never been encountered before. Nothing was changed between the last successful build and this one, and clearing the NuGet cache had no effect. The error can be reproduced locally on MSBuild 17.1.0 and in CI on MSBuild 17.0.6, so it seems very unlikely that the issue is related to the release of MSBuild 17.1.0.Verbose Logs
The full diagnostic log unfortunately reveals too much proprietary information to disclose publicly (including the name of every single file in the repository, for example), but I suspect the remainder of the contents will not be of much assistance in this particular case.
The text was updated successfully, but these errors were encountered: