core icon indicating copy to clipboard operation
core copied to clipboard

build failed

Open lallikrishna opened this issue 2 years ago • 1 comments

C:\Users\lalli\MyApp\Program.cs(2,1): error CS8802: Only one compilation unit can have top-level statements. [C:\Users\lalli\MyApp\MyApp.csproj]

The build failed. Fix the build errors and run again.

lallikrishna avatar Jan 16 '23 04:01 lallikrishna

Hello @lallikrishna, could you please check that you don't have another files in your project with top-level statements? You may find more examples here https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9#top-level-statements

greenEkatherine avatar Jan 16 '23 10:01 greenEkatherine

Sometimes I've seen this happened when the dotnet new command is run twice, once at the user's folder (at C:\users\lalli) and then another time after the user has done cd MyApp. You could delete the MyApp folder and start over.

mairaw avatar Jan 21 '23 01:01 mairaw