Pryaxis / TShock

☕️⚡️TShock provides Terraria servers with server-side characters, anti-cheat, and community management tools.
GNU General Public License v3.0
2.41k stars 377 forks source link

Plugin manager crashes if specified nuget package contains xml #2895

Open sgkoishi opened 1 year ago

sgkoishi commented 1 year ago

Reproduction steps (if applicable)?

  1. TShock.Server plugins sync
  2. Press y to continue

Any stack traces or error messages (if known)?

Unhandled exception: System.IO.FileNotFoundException: Could not find file '....xml'.
File name: '....xml'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Interop.CheckIo(Error error, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite)
   at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
   at TShockPluginManager.Nugetter.InstallPackage(SourcePackageDependencyInfo pkg, String pkgPath, PackageReaderBase packageReader)
   at TShockPluginManager.Nugetter.DownloadAndInstall(PackageIdentity[] userRequest)
   at TShockPluginManager.NugetCLI.Sync()
   at System.CommandLine.Invocation.AnonymousCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()

https://github.com/Pryaxis/TShock/blob/6e589ffaeed99fa1b1559a5aa18c375d04961fb3/TShockPluginManager/Nuget.cs#L261-L265

https://github.com/Pryaxis/TShock/blob/6e589ffaeed99fa1b1559a5aa18c375d04961fb3/TShockPluginManager/Nuget.cs#L306

All files in the NuGet package were being copied, but the XMLs were excluded and not extracted before the attempt to copy. https://github.com/Pryaxis/TShock/blob/6e589ffaeed99fa1b1559a5aa18c375d04961fb3/TShockPluginManager/Nuget.cs#L62-L66