Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net Core: Program does not contain a static 'Main' method suitable for an entry point

Tags:

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.

like image 804
Peter Avatar asked Dec 15 '16 04:12

Peter


1 Answers

Solved a similar issue by explicitly setting the OutputType tag in my classlib.csproj file:

<PropertyGroup>
  <TargetFramework>netcoreapp2.2</TargetFramework>
  <OutputType>Library</OutputType>
</PropertyGroup>
like image 81
ENDEESA Avatar answered Sep 28 '22 09:09

ENDEESA