Asp.Net Core: Program does not contain a static 'Main' method suitable for an entry point
Solved a similar issue by explicitly setting the OutputType
tag in my classlib.csproj file:
<PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <OutputType>Library</OutputType> </PropertyGroup>
To avoid the error of "Program does not contain a static 'Main' method suitable for an entry point" in class library, Remove emitEntryPoint from buildOptions-
"buildOptions": {
"emitEntryPoint": true
},
emitEntryPoint tells the compiler whether to create a Console Application or a Library. For more info refer this post
If the Main method has an async modifier, make sure that the selected C# language version is 7.1 or higher. You can fix the issue by adding below element to the .csproj file manually. Reference
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>