I have a .net core app that I want to run in background, but I can't seem to get rid of the console window of Kestrel. Is there any way to hide it without running the app as a windows service? I've tried to remove any reference related to Logger, it didnt help.
here is my Program.Main:
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true)
.Build();
var hostingUrl = config.GetValue<string>("HostingUrl");
if (string.IsNullOrEmpty(hostingUrl))
{
var xmlString = File.ReadAllText(Consts.WebHostBaseFolder + "\\web.config");
var confDoc = XDocument.Parse(xmlString);
hostingUrl = confDoc.Element("configuration").Element("appSettings")?.Elements("add")?.FirstOrDefault(e => e.Attribute("key").Value == "HostingUrl")?.Attribute("value")?.Value ?? "";
}
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Consts.WebHostBaseFolder)
.UseStartup<Startup>()
.UseUrls(hostingUrl)
.Build();
host.Run();
Thanks