Does not contain a static ‘main’ method suitable for an entry point
using CountryAPI.Models;
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSingleton<ICountryService, CountryService>(); // Singleton service
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); });
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
}
}
Program runs in Visual Studio but shows CSC 5001 error when using docker build command in terminal.
- Tried changing the output type to exe
- Made sure program was in compile mode
- Added a main method
- Restarted everything
New contributor
Prottasha D’cruze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.