wiringpi-dotnet icon indicating copy to clipboard operation
wiringpi-dotnet copied to clipboard

.NET 5 Single file deployment throws exception

Open raphibolliger opened this issue 3 years ago • 1 comments

Since .NET 5 the Assembly.Location API returns an empty string when the app is deployed as single file executable. https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file

This prevents the library from using with a single file deployment.

Error The basePath variable will be empty. https://github.com/unosquare/wiringpi-dotnet/blob/9746619117ab82ca16d80b51de0d4a67839e81c9/src/Unosquare.WiringPi/Resources/EmbeddedResources.cs#L36 Path.Combine later on will throw an exception. https://github.com/unosquare/wiringpi-dotnet/blob/9746619117ab82ca16d80b51de0d4a67839e81c9/src/Unosquare.WiringPi/Resources/EmbeddedResources.cs#L42

Exception

System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
   at System.IO.Path.Combine(String path1, String path2)
   at Unosquare.WiringPi.Resources.EmbeddedResources.ExtractAll()
   at Unosquare.WiringPi.BootstrapWiringPi.Bootstrap()
   at Unosquare.RaspberryIO.Pi.Init[T]()
   at HorseFeeder.Raspberry.InitializeService.InitializeRaspberryPi()

Possible solution I'm not 100% sure but maybe it's possible to use AppContext.BaseDirectory to get the basePath. https://docs.microsoft.com/en-us/dotnet/api/system.appcontext.basedirectory?view=net-5.0#System_AppContext_BaseDirectory

raphibolliger avatar Jan 16 '21 09:01 raphibolliger

We are looking for maintainers, you can apply at https://adoptoposs.org/p/67b02bee-a00e-446a-a321-c1a6449014bc

geoperez avatar Feb 15 '21 14:02 geoperez