Program does not contain a static 'Main' method suitable for an entry point
See original GitHub issueHi,
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:
- Created 6 years ago
- Reactions:1
- Comments:11 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Try replacing
<LangVersion>Latest</LangVersion>
with<LangVersion>7.1</LangVersion>
Same issue here! in 3.1