When RabbitMQ Stream client is used in a project that is published as a single file, an Exception is thrown:
System.TypeInitializationException: The type initializer for 'RabbitMQ.Stream.Client.Version' threw an exception.
---> System.ArgumentException: The path is empty. (Parameter 'path')
at System.IO.Path.GetFullPath(String path)
at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
at RabbitMQ.Stream.Client.Version..cctor() in /_/RabbitMQ.Stream.Client/Version.cs:line 15
When published as a single file, the assemblies are bundled together and do not exist as individual files. Assembly.Location returns an empty string in this case, and this causes FileVersionInfo.GetVersionInfo to fail.
In my project, I use Assembly.GetName().Version.ToString() to log the assembly Version, maybe this could also be used in this case.
Reproduction steps
Publish a project that uses RabbitMQ Stream Client as single file: dotnet publish --self-contained true -p:PublishSingleFile=true test.csproj
Start the published executable
Expected behavior
RabbitMQ Stream Client should support single file publish
Describe the bug
When RabbitMQ Stream client is used in a project that is published as a single file, an Exception is thrown:
When published as a single file, the assemblies are bundled together and do not exist as individual files. Assembly.Location returns an empty string in this case, and this causes FileVersionInfo.GetVersionInfo to fail.
In my project, I use
Assembly.GetName().Version.ToString()
to log the assembly Version, maybe this could also be used in this case.Reproduction steps
dotnet publish --self-contained true -p:PublishSingleFile=true test.csproj
Expected behavior
RabbitMQ Stream Client should support single file publish
Additional context
https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/warnings/overview