JamesNK / Newtonsoft.Json

Json.NET is a popular high-performance JSON framework for .NET
https://www.newtonsoft.com/json
MIT License
10.71k stars 3.24k forks source link

Newtonsoft.Json 13.0.3 NuGet fails to install to .NET Framework 4.8 projects #2897

Closed jdfurlan closed 11 months ago

jdfurlan commented 11 months ago

Expected behavior

Newtonsoft.Json 13.0.3 NuGet installs cleanly with no errors.

Actual behavior

Package Manager output shows the below:

Attempting to gather dependency information for package 'Newtonsoft.Json.13.0.3' with respect to project 'ConsoleApp1', targeting '.NETFramework,Version=v4.8'
Gathering dependency information took 62 ms
Attempting to resolve dependencies for package 'Newtonsoft.Json.13.0.3' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Newtonsoft.Json.13.0.3'
Resolved actions to install package 'Newtonsoft.Json.13.0.3'
Adding package 'Newtonsoft.Json.13.0.3' to folder 'C:\Users\dev.CLOUDDEV\source\repos\ConsoleApp1\packages'
Install failed. Rolling back...
Package 'Newtonsoft.Json.13.0.3' does not exist in project 'ConsoleApp1'
Package 'Newtonsoft.Json.13.0.3' does not exist in folder 'C:\Users\dev.CLOUDDEV\source\repos\ConsoleApp1\packages'
Executing nuget actions took 714 ms
System.UnauthorizedAccessException: Access to the path 'C:\Users\dev.CLOUDDEV\source\repos\ConsoleApp1\packages\Newtonsoft.Json.13.0.3\.signature.p7s' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.OpenFile(String path, FileAccess access, SafeFileHandle& handle)
   at System.IO.File.SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc)
   at NuGet.Packaging.ZipArchiveExtensions.Testable.UpdateFileTimeEntry(String fileFullPath, DateTime dateTime)
   at NuGet.Packaging.PackageFolderReader.CopyFiles(String destination, IEnumerable`1 packageFiles, ExtractPackageFileDelegate extractFile, ILogger logger, CancellationToken token)
   at NuGet.Packaging.PackageReaderBase.CopyFilesAsync(String destination, IEnumerable`1 packageFiles, ExtractPackageFileDelegate extractFile, ILogger logger, CancellationToken cancellationToken)
   at NuGet.Packaging.PackageExtractor.<ExtractPackageAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.ProjectManagement.FolderNuGetProject.<>c__DisplayClass13_0.<<InstallPackageAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLockedAsync>d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLockedAsync>d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.ProjectManagement.MSBuildNuGetProject.<InstallPackageAsync>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteInstallAsync>d__97.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__86.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__86.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__86.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__85.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__84.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.VisualStudio.NuGetProjectManagerService.<>c__DisplayClass20_0.<<ExecuteActionsAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.VisualStudio.NuGetProjectManagerService.<CatchAndRethrowExceptionAsync>d__32.MoveNext()
Time Elapsed: 00:00:01.8687560
========== Finished ==========

Steps to reproduce

Notes

elgonzo commented 11 months ago

Not reproducible. The problem appears to be by something somewhere in your environment. The read-only flag being set on the .p7s file is not coming from the Newtonsoft.Json nuget package itself.

You can download the newtonsoft.json.13.0.3.nupkg nuget package of the library from nuget.org yourself (https://www.nuget.org/packages/Newtonsoft.Json) and check the content with some ZIP archive tool (nuget packages are ZIP archives). The read-only flag is NOT set in the nuget package (nor is any other file attribute set on the .p7s file in the package). I unfortunately can't help you with any advice of what could possibly cause the read-only flag being set on the .p7s file on your system. But it is not the fault of the Newtonsoft.Json 13.0.3 nuget package, as can be easily verified by inspecting the nuget package as provided by nuget.org itself.

jdfurlan commented 11 months ago

Confirmed that an old version of the nuget was sitting in my packages folder. After deleting, it installed correctly. Somehow the signature file set as read-only. Thanks for looking.