I am trying to port my Asp.Net WebApi project, based on the Onion Architecture design approach, over to Asp.Net Core. However, when I build my class libraries, the compiler is looking for the static Main method in Program.cs and I am getting:
C:\Projects\Some\src\Some.Core\error CS5001: Program does not contain a static 'Main' method suitable for an entry point
I am assuming that there should be only one Program.cs / entry point for the overall solution, and that is sitting inside of my WebApi project. Am I incorrect? Otherwise, how do I resolve this error? I falsely assumed that "emitEntryPoint": true
served this purpose.
Here is an example of my class library's project.json:
{
"version": "1.0.0-*",
"description": "Some.Core Class Library",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Routing": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.Identity": "1.0.0",
"Microsoft.Extensions.Configuration": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"
},
"frameworks": {
"netstandard1.6": {
"dependencies": {
"NETStandard.Library": "1.6.0"
}
}
},
"runtimes": {
"win7-x64": {}
}
}
Suggestions appreciated.
Solved a similar issue by explicitly setting the OutputType
tag in my classlib.csproj file:
<PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <OutputType>Library</OutputType> </PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With