Closed VoidMonk closed 4 years ago
I'm not sure I understand the issue here - you're including the AspNetCore package - and it references the ASP.NET Core bits, that looks correct to me.
If you're only using shared pieces, you are free to reference only the StackExchange.Exceptional.Shared
package if only needing the common bits - is that the confusion? Apologies if that's not helpful...I'm trying to understand what the issue is here.
Can you please elaborate on what should be happening if the above doesn't help?
@NickCraver Thank you for your reply.
This isn't a ASP.NET Core project, but still referencing the StackExchange.Exceptional.AspNetCore
package (as suggested in the docs), so maybe that's causing the confusion.
The problem is that a .NET Core Worker project, like a .NET Core Console app, that needs StackExchange.Exceptional
through one package or another, should generate the framework name as Microsoft.NETCore.App
in its published project.runtimeconfig.json
file, instead of Microsoft.AspNetCore.App
which causes the worker to fail when run.
I'll try using the StackExchange.Exceptional.Shared
package instead.
Tried using StackExchange.Exceptional.Shared
package instead of StackExchange.Exceptional.AspNetCore
in the Worker project, but then ExceptionalSettings
is not available for configuration:
var exceptionalSettings = configuration.GetSection("Exceptional").Get<ExceptionalSettings>();
Exceptional.Configure(exceptionalSettings);
Ah, you can make your own - this is mostly around the Core/not split. For example:
public class ExceptionalSettings : ExceptionalSettingsBase { }
...since you're not actually adding any bits specific to ASP.NET Core.
Cool, but Exceptional
isn't available too, for Exceptional.Configure()
.
Seems like Exceptional
doesn't have a Configure
method when using the StackExchange.Exceptional.Shared
package. Any other way to use Exceptional in a .NET Core Worker project?
Figured out a workaround, by using the StackExchange.Exceptional.Shared
package, and creating a wrapper class for Exceptional
based on StackExchange.Exceptional/src/StackExchange.Exceptional.AspNetCore/Exceptional.cs
Hi, I came across this strange issue when publishing
StackExchange.Exceptional
as part of a .NET Core Worker service, making it fail to run.When a worker project references the
StackExchange.Exceptional.AspNetCore
package (as in docs), its publishedproject.runtimeconfig.json
file includes the framework name asMicrosoft.AspNetCore.App
instead ofMicrosoft.NETCore.App
.Actual error message when worker is run on a machine with .NET Core runtime (worker project shouldn't need the ASP.NET Core runtime):
Any idea why this happens, and how to fix it?
Environment:
Steps to reproduce:
Create new worker project:
Add the Exceptional package reference to the
MyWorker.csproj
project file:Build and publish the project:
Open the
publish\worker\MyWorker.runtimeconfig.json
file, which will show the incorrect framework name asMicrosoft.AspNetCore.App
:Without the Exceptional package reference, the build and publish step generate a valid runtime config (with framework name as
Microsoft.NETCore.App
).