tareqimbasher / NetPad

A cross-platform C# editor and playground.
MIT License
1.31k stars 67 forks source link

NetPad fails to load NuGet package when script is saved with the same name. #163

Closed lpreiner closed 7 months ago

lpreiner commented 7 months ago

Executing a script with the same name as an included NuGet package results in System.IO.FileNotFoundException.

Steps to reproduce:

  1. Create a new script
  2. Add a NuGet package (e.g. Quartz)
  3. Populate some code that leverages the package
  4. Execute the script (execution will succeed)
  5. Save the script with the same name as the added package (e.g. Quartz)
  6. Execute the script (execution will fail with FileNotFoundException)
  7. Quit NetPad
  8. Open NetPad
  9. Open script (e.g. Quartz)
  10. Execute the script (execution continues to fail)
  11. Rename script to something other than the package name (e.g. Quartz123)
  12. Execute the script (execution will succeed)
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Quartz, Version=3.8.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4'. The system cannot find the file specified.

File name: 'Quartz, Version=3.8.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4'

Platform: Mac, arm64. .NET 8

Example script, Quartz.netpad

cb1d840b-f215-4d6f-a7f3-118e82c87f2a
{"config":{"kind":"Program","targetFrameworkVersion":"DotNet8","namespaces":["System","System.Collections","System.Collections.Generic","System.Data","System.Diagnostics","System.IO","System.Linq","System.Linq.Expressions","System.Net.Http","System.Reflection","System.Text","System.Text.RegularExpressions","System.Threading","System.Threading.Tasks","System.Xml","System.Xml.Linq","System.Xml.XPath"],"references":[{"discriminator":"PackageReference","packageId":"Quartz","version":"3.8.0","title":"Quartz.NET"}]},"dataConnection":null}
#Code
using Quartz.Core;
QuartzScheduler.VersionMajor.Dump();
tareqimbasher commented 7 months ago

Thanks for the repro, will get it fixed!