So I want to create new dotnet projects directly from my c# code, presumably by running a dotnet new
command or something of the like, but I can’t find the syntax for it. Pretty much everything I’ve googled comes up with how to create a project via the VS GUI or the CLI, save for one discussion.
I've tried a few different iterations of something like this, with no luck. It just hangs after running the waitforexit line. Is this in the ballpark, or is there a better way?
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = @$"dotnet new foundation -n HelloApiWorld -e ""Hello"" -en ""hello"" -la ""h""",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = false,
WorkingDirectory = @"C:\testoutput"
}
};
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();