I am trying to run a hello world C# code from command line and this is the batch file. Tried searching for it but most of the questions are about the XML file reader, I am not reading any XML files.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild "E:\a\c.cs" /p:Configuration=Debug;DeployOnBuild=True;PackageAsSingleFile=False;outdir=E:\a
and this is c.cs
class c {
public static void Main() {
System.Console.Clear();
System.Console.WriteLine("hey");
System.Console.ReadKey();
}
}
and the error
msbuild expects a project file or a solution file as input:
https://msdn.microsoft.com/en-us/library/ms164311.aspx
What you want to do is run the c# compiler directly:
Compiling/Executing a C# Source File in Command Prompt
If you are running dotnet with the following command while running.
dotnet run --project [project_name].dll
You can run the following instead of the above command.
dotnet [project_name].dll
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With