This is probably because you're setting the artifacts-path
to be the project folder (.\test
). You could set it to .\test\artifacts
or another nested folder, but typically you'd use this flag for configuring a common artifact folder location for all projects in a solution to simplify CI/CD pipelines. So normally you'd set it to a folder directly inside your solution folder, or somewhere else entirely.
https://learn.microsoft.com/en-us/dotnet/core/sdk/artifacts-output
All build outputs from all projects are gathered into a common location, separated by project. A common location makes it easy for tooling to anticipate where to find the outputs.
For a simple hello world console app you can just omit that flag all together, though.
As for how to define a method/function: if there's code that you want the compiler to wrap a fake Main
method around then it goes at the top, so your declarations can go at the bottom, but in reality it's probably best to avoid Program.cs being too complex & just moving these functions out.
Print();
static void Print() {
Console.Write("Hello, World!");
}