NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 250 forks source link

Report the path when unable to read corrupted .nupkg.metadata #13763

Open KirillOsenkov opened 1 week ago

KirillOsenkov commented 1 week ago

Pick a .nupkg.metadata file from your package cache and replace the contents with some NULL bytes, or corrupt it otherwise Use RestoreEx that reads that file

Expected: nice error message The file 'C:\Users\user\.nuget\packages\microsoft.win32.systemevents\8.0.0\.nupkg.metadata' is corrupted. It is recommended to clear the package cache using dotnet nuget locals all --clear and then retry the restore.

Actual:

d:\Current\bin\amd64\NuGet.RestoreEx.targets(19,5): error : Found invalid data while decoding. [D:\git\move\temp-msbuild-restore\dirs.proj]
d:\Current\bin\amd64\NuGet.RestoreEx.targets(19,5): error :    at NuGet.Packaging.NupkgMetadataFileFormat.Read(TextReader reader, ILogger log, String path) [D:\git\move\temp-msbuild-restore\dirs.proj]
d:\Current\bin\amd64\NuGet.RestoreEx.targets(19,5): error :    at NuGet.Packaging.NupkgMetadataFileFormat.Read(Stream stream, ILogger log, String path) [D:\git\move\temp-msbuild-restore\dirs.proj]
d:\Current\bin\amd64\NuGet.RestoreEx.targets(19,5): error :    at NuGet.Common.FileUtility.SafeRead[T](String filePath, Func`3 read) [D:\git\move\temp-msbuild-restore\dirs.proj]

See also: https://github.com/NuGet/NuGet.Client/pull/4660 https://github.com/NuGet/Home/issues/10882

dotnet-policy-service[bot] commented 1 week ago

Issue is missing Type label, remember to add a Type label