Using Visual Studio for exercises from Code Academy’s virtual console.
I open C# file in Visual Studio (2022 version). When entering ‘dotnet run’ in Powershell, it returns:
‘Couldn’t find a project to run. Ensure a project exists in C/Users/(username)/source/repos, or pass the path using –project.’
What I don’t get is, the .cs file is there, despite terminal saying it isn’t.
Thank you and happy holidays
2
Answers
You can use an existing template that visual studio provides in File -> Add -> New Project. Everything will be set up automatically for you (like .csproj, your main .cs file, etc) so you can just build and run that.
For something barebones, pick the C# console app and then just do your Code Academy stuff there.
When using dotnet run, you need to pay attention to the following points:
In addition, you can also just use the button to run the program that comes with Visual Studio, and Visual Studio will automatically compile the program for you. Or you can directly press F5 to quickly start