question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Program does not contain a static 'Main' method suitable for an entry point

See original GitHub issue

Hi,

I have a netcoreapp2.0 project that failed to build with the following error when I tried to build it with dotnet build:

CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point

Then I open the project in Visual Studio (d15prerel 26629.02), the project built fine in VS, and after that the error is gone from ‘dotnet build’ and it succeeds.

After I run ‘dotnet clean’, ‘dotnet build’ starts failing with the same error

Here is my project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
    <!-- omitted AssemblyName and RootNamespace properties -->
    <LangVersion>Latest</LangVersion>
    <PackageTargetFallback>$(PackageTargetFallback);portable-net40+sl5+win8+wp8+wpa81;portable-net45+win8+wp8+wpa81</PackageTargetFallback>
  </PropertyGroup>

  <ItemGroup>
    <!-- some project references to other projects -->
  </ItemGroup>

</Project>

There is only one Program.cs file in the project, it has this entry point:

namespace ...
{
    static class Program
    {
...
        public static async Task Main(string[] args)
        {
        }
...

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
LordDraagonLivecommented, Aug 8, 2018

Try replacing <LangVersion>Latest</LangVersion> with <LangVersion>7.1</LangVersion>

5reactions
naughtyGitCatcommented, Jun 16, 2020

Same issue here! in 3.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does not contain a static 'main' method suitable for an entry ...
If you do have a Main method but still get this error, make sure that the file containing the Main method has "Build...
Read more >
Compiler Error CS5001
This error occurs when no static Main method with a correct signature is found in the code that produces an executable file. It...
Read more >
Program does not contain a static 'Main' method suitable ...
The issue with your code is that your Main method not declared as neither public nor static. The correct definition is: public static...
Read more >
CS5001 C# Program does not contain a static 'Main' ...
The problem here is the method is marked as private which is not legal for the “Main” method. Change that to internal or...
Read more >
C# - Changing Main method to async causes entry point error
A fix for the error: "Program does not contain a static 'main' method suitable for an entry point" when changing a main method...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found