Skip to content

Instantly share code, notes, and snippets.

@enisn
Last active April 16, 2020 17:59
Show Gist options
  • Save enisn/1397657e205440610db9f1559a2368d4 to your computer and use it in GitHub Desktop.
Save enisn/1397657e205440610db9f1559a2368d4 to your computer and use it in GitHub Desktop.
Multi-Targeting Program.cs
#if NETCOREAPP2_2
using Microsoft.AspNetCore;
#endif
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace Sample.WebService
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
#if NETCOREAPP2_2
public static IWebHostBuilder CreateHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
#endif
#if NETCOREAPP3_0 || NETCOREAPP3_1
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment