Getting error CS8802: Only one compilation unit can have top-level statements.
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
bash-3.2$ cd MyApp bash-3.2$ dotnet new console -o MyApp
bash-3.2$ dotnet run
Can you help please ? I am on a Mac (Catalina 10.15.7) If I do: bash-3.2$ dotnet --version 6.0.302
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.
This issue is stale because there has been no response to a request for more information for 7 days.
This issue was closed because there was no response to a request for more information for 10 days.
@mairaw thank you very much.