-
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
error NU1403: The package Microsoft.CSharp.4.0.1 sha512 validation failed. #7921
Comments
It looks like it may not be the NuGetFallbackFolder, but the I think https://github.com/NuGet/Home/wiki/Nupkg-Metadata-File |
The fallback folder issues are due to #7414. It's a bug on Dotnet CLI side with the LZMA tool. The bug summarizes the findings the actionable. Unfortunately there will be no changes to the LZMA tool as it's being completely done away with in .NET Core 3.0. What you are articulating sounds like the bug in #7682, which should have been fixed in 2.2.104. Are you using the same version everywhere? The property you are using to disable the fallback folder seems right: <DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder> But you need to make sure the lock file is generated with that property. Also, are you using the same version of the dotnet sdk on all instances? |
No matter what I do the lock file that is generated while in a docker sdk container contains I created a little app to troubleshoot this:
|
@ctaggart Thanks |
@nkolev92, steps to reproduce:
Various other troubleshooting:
Nothing has worked. I've also tried Worth noting that the <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode>true</RestoreLockedMode> |
I found this pretty strange. I was expecting these to hashes to match.
On Windows:
|
@ctaggart it will also be worth checking what's the value in And btw what's this value |
@ctaggart The first hash value is the one that's written in the fallback folder prior to the LZMA is run. |
The way that the public static void GenerateNupkgMetadataFile(string nupkgPath, string installPath, string hashPath, string nupkgMetadataPath)
Now prior to the LZMA zips them, the package is signed. |
It seems to me like the .nupkg.metadata file in the fallback folder has the same value as the sha512. Do you see any issues if you completely disable the fallback folder? |
I'm seeing this for Microsoft.NETCore.Targets.1.1.0 (and other packages), I've disabled the fallback folder, and still have the issue. I've also pinned the dotnet sdk to 2.2.105 in global.json. Locally I'm running macOS (and generating the lock files), it's building and failing on a docker container. |
The expectation is that I am using that same dotnet sdk version, such as 2.2.105, I can lock the depdendencies on one system (Windows) and then restore the depdendencies on another system (Docker). That doesn't work and I haven't found a work-a-round. dotnet sdk 2.2.105 on Windows produces this: "Microsoft.CSharp": {
"type": "Transitive",
"resolved": "4.0.1",
"contentHash": "eEgt/ktABPBa/1xBex3M6b7C4dYsGQ0HWuwe9Xhflgu4cvn4a5VvFSLj5vyTKkp+hKrVpTRdqTXDTAxsIL1Reg==" That
I begin troubleshooting by recreating the lock files on the docker image and it says the contentHash is: ctaggart/froto@83f9bd3#diff-ce2cbfcdedae8d0b839697df83de2102R67 "Microsoft.CSharp": {
"type": "Transitive",
"resolved": "4.0.1",
"contentHash": "17h8b5mXa87XYKrrVqdgZ38JefSUqLChUQpXgSnpzsM0nDOhE40FTeNWOJ/YmySGV6tG6T8+hjz6vxbknHJr6A==", Global Packages in Windows
NuGetFallbackFolder in Windows
NuGetFallbackFolder in Docker
How do I get the contentHash?I was expecting using (var stream = File.OpenRead(zipPath))
using (var packageReader = new PackageArchiveReader(stream, leaveStreamOpen: true))
{
var contentHash = packageReader.GetContentHash(CancellationToken.None);
Console.WriteLine(contentHash); |
Update from me: I generate a lock file that then goes on to work in CI (docker for me) after deleting the package cache folder. |
My mistake was not locking down my NuGet sources with a NuGet.Config, <?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration> The <Project>
<PropertyGroup>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode>true</RestoreLockedMode>
<NoWarn>NU1603</NoWarn>
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
</Project> I then best to clear all the local nuget caches and regenerate the lock files.
It is working now for me. Some of the hash's don't make sense to me still, but at least it is consistent across platforms when you take the NuGetFallbackFolder's completely out of the picture. |
Thanks for following up @ctaggart We are sorry that we could not make this easier. Why did the |
@nkolev92 I just tested with it enabled and it doesn't appear to have been a park of the issue. Thanks for clearing that up. |
Oh, perfect. That's good then. |
…ibman (#788) * build(pipeline): Added NuGet package caching Add CacheBeta task to azure-pipelines.yml to enable NuGet package caching and hopefully speed up CI builds. Enable creation of packages.lock.json for projects built in pipeline to enable above. * build(pipeline): Added NuGet cache tasks to other stages * build(pipeline): Added LibMan caching * build(pipeline): Fixed "pipeline[s]" typos * build(csproj): Generated packages.lock.json * build(cache): Fixed libman cache key * build(cache): Fixed cache step not using template * build(cache): Changed libman cache key * build(pipeline): Fixed cache template path in prepare-integration-test-steps.yml * pipeline(cache): Made NuGet cache unique per OS * build(nuget): Workaround for failed restore May be encountering this issue: microsoft/azure-pipelines-tasks#11449 Suggested workarounds taken from this comment: NuGet/Home#7921 (comment) * build(cache): Added OS-specific libman cache paths * build(pipeline): Moved variables to main yml file * Remove RestorePackagesWithLockFile from csproj's because that is handles by Directory.Build.Props * Remove RestoreLockedMode from Directory.Build.Props because you want to be able to update the package lock files as a developer * Delete not needed nuget.config files * Regenerate package lock files * Set restore locked mode true on azure pipelines * Never RestoreLockedMode for integration test projects because they are used in an integrationtest scenario * Only use nuget package folders if they contain an entry for our OS, otherwise try deploying embedded vstest binaries * Remove zero check on _vstestPaths * Check if paths exists * ! <> !! * Install dotnet core before running unit tests * fix sonarqube major issue * Update package lock with McMaster.Extensions.CommandLineUtils 2.4.3 * switch back unit test run step * populate cache before running unit tests * Revert "populate cache before running unit tests" This reverts commit a9c5923. * restore caches as first steps everywhere
If I'm using the latest .NET Core 3.0.100 SDK, should this all work as advertised with just this in my <Project>
<PropertyGroup>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
</Project> |
It should, but you may need to clear out any packages from you cache that would have been restored with an old nuget. Going forward, you won't get into this state. |
This does not seem to be the case. I get different hashes when I build with:
It seems you still require:
|
- Fallback folder packages don't have the same hash as packages from NuGet.org: NuGet/Home#7921 (comment)
Hi, I'm using dotnet SDK 3.0, and I'm introducing a lock file so that I can cache the nuget restore on azure pipelines. I've added When I push this, the azure pipelines restore task fails, and I see lots of issues e.g.:
This was running previously. My nuget restore task is configured to use feeds in my nuget.config file, which I do have in the root of the project: <?xml version="1.0" encoding="utf-8"?>
<configuration>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="myget" value="https://www.myget.org/F/[redacted]/index.json" />
</packageSources>
<disabledPackageSources />
</configuration> Can anyone advise? |
Had this problem with 3.1.100. I deleted my nuget cache This fixed the issue. |
Reporting back:
|
The fix suggested by @ctaggart worked for me too but doesn't deleting the packages.lock.json file while building the docker image defeat the purpose of trying to enforce the same package versions everywhere? Wouldn't NuGet pull new versions of packages (if they were available) once the lock file is deleted? |
I've tried everything in this thread, Yet when my build runs on azure pipelines I get these errors:
Some info about my setup:
Note the additional authenticate step is necessary before doing the My NuGet.config:
My
This regenerated all the lock files clean. I committed them, pushed up the changes to trigger a new build on azure pipelines and I see this:
I have no ideas how to solve this issue. Any help much appreciated as I have lost so much time on this now. I have checked that on my PATH I am using latest NuGet:
This is the same version of NuGet that I am installing in the pipelines job - you can see that above in my pipelines yml. I have a global.json in my /src directory where my sln, and nuget.config is:
My pipelines job uses the following agent:
I have checked this agent - it has sdk version 3.1.201 already installed. |
I've got to the bottom of my issue. @ctaggart 's steps do work, but not if you accidentally use the latest preview sdk (3.1.300-preview-015095) when generating the lock files locally. I was doing the following to regenerate the lock files locally:
The azure pipelines hosted agent is on dotnet sdk This caused all the nuget package hash mismatches from what I can tell. Using a global.json correctly so that However that leaves me wondering if this is a breaking change in |
See more about the fix here: NuGet/Home#7921 (comment).
Honestly, there are multiple msbuild settings that should be changed from defaults if you're hoping for reproducible builds. We're centralizing them into the Dotnet.ReproducibleBuilds.Isolated package. It's still in the early phases, but attempts to change msbuild defaults to avoid dependencies on anything machine/install specific (e.g. the nuget fallback folder that might have who-knows-what variants of real packages in it, and can be effected by installs of different dotnetsdk versions) |
Not sure where the best place to ask this question would be, but we are encountering the same error, NU1403, so I am curious what the status of the reproducible builds project is? |
Please refer to #7921 (comment) for addressing the specific NU1403 problems you may have. |
Thank you for the quick reply, @nkolev92. I did see that comment, and tried clearing my NuGet cache to no avail, but my (admittedly limited) understanding of the other steps is that any of them would subsequently require recreating the lock file. Clearly this will work (even if none of those steps are taken and no configuration is changed), but it also removes one of the key security guarantees lock files offer, preventing us from confirming that the package hasn't been tampered with on the NuGet server (or en route from the NuGet server). It would be somewhat like having invested in the construction of a gate only to then open it anytime anyone knocks. Please correct me if I am missing something as I realize that my analogy may be greatly oversimplifying. (I am also happy to move this discussion to a more appropriate venue; I just don't know what that would be yet.) |
You only recreate the lock file once, once you've excluded all the local packages that are basically seen as "tampered" by nuget. The tldr of this whole is that there are packages in the SDK fallback fodlers that are effectively seen as tampered because the compression algorithm changed the zip. |
I'm trying to add nuget 4.9 lock files, but I get the error:
Steps to reproduce:
Checkout the
lock
branch from ctaggart/froto#104, then restore using docker:My hunch is that the nuget is NuGetFallbackFolder is causing problems. It includes nuget packages that don't match NuGet.org. WHY DOES IT HAVE PACKAGES THAT DON'T MATCH NUGET.ORG?
The Froto.Serialization.Test.fsproj has a lock to:
It matches what is downloaded from nuget.org:
The docker image NuGetFallbackFolder contentHash does not match:
At least the NuGetFallbackFolder on my Windows PC matches the docker image:
Is there a way to disable NuGetFallbackFolder from the lock check? I tried this without luck:
If you are going to continue shipping NuGet packages in NuGetFallbackFolder, can you make sure they match NuGet.org?
The text was updated successfully, but these errors were encountered: