core icon indicating copy to clipboard operation
core copied to clipboard

Getting error CS8802: Only one compilation unit can have top-level statements.

Open ashDog opened this issue 3 years ago • 2 comments

Problem encountered on https://dotnet.microsoft.com/en-us/learn/dotnet/hello-world-tutorial/run Operating System: macos

Provide details about the problem you're experiencing. Include your operating system version, exact error message, code sample, and anything else that is relevant.

I installed .NET today for the first time ever and ran the following steps as instructed in the Hello World tutorial: bash-3.2$ dotnet new console -o MyApp -f net6.0

Screenshot 2022-08-03 at 16 08 21

bash-3.2$ cd MyApp bash-3.2$ dotnet new console -o MyApp

Screenshot 2022-08-03 at 16 09 28

bash-3.2$ dotnet run

Screenshot 2022-08-03 at 16 10 43

Can you help please ? I am on a Mac (Catalina 10.15.7) If I do: bash-3.2$ dotnet --version 6.0.302

ashDog avatar Aug 03 '22 15:08 ashDog

Hi @ashDog! I usually see this error when the dotnet new command has been ran twice on different folders in the same hierarchy. In your screenshot above, it seems you did cd MyApp and then ran the command again, creating a second project inside that folder. You could just delete the top MyApp folder and start over.

Let us know if this helps.

mairaw avatar Aug 03 '22 18:08 mairaw

This issue is stale because there has been no response to a request for more information for 7 days.

github-actions[bot] avatar Aug 10 '22 19:08 github-actions[bot]

This issue was closed because there was no response to a request for more information for 10 days.

github-actions[bot] avatar Aug 13 '22 20:08 github-actions[bot]

@mairaw thank you very much.

codes-of-yildiray avatar Sep 23 '23 19:09 codes-of-yildiray