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]
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:
See also: https://github.com/NuGet/NuGet.Client/pull/4660 https://github.com/NuGet/Home/issues/10882