-2

Is it possible to get data from the .csproj file to be passed to a custom health check in a .NET application?

I currently have endpoints.MapCustomHealthChecks("ApplicationName", "ApplicationVersion"); in my Program.cs. It works fine except that I need to make a code update any time I change the version. However both parameters are in my .csproj file so I was wondering if it's possible to use these.

runnerpaul
  • 5,942
  • 8
  • 49
  • 118

1 Answers1

0
var publisherName = Assembly.GetEntryAssembly().GetName().Name;
var publisherVersion = Assembly.GetEntryAssembly().GetName().Version.ToString();
endpoints.MapCustomHealthChecks(publisherName, publisherVersion);
runnerpaul
  • 5,942
  • 8
  • 49
  • 118