NET Core Console App` from a batch script and redirect the exceptions to a file.I am also providing arguments to this script:
My script so far:
rem **calling C# solution from batch*******
@echo received from python param1:%1 , param2:%2 ,param3:%3
start "Dotnet Test" D:\adi\NET\Bench\Bench\bin\Debug\netcoreapp2.1\Bench.dll dotnet %1 %2 %3 2>output.txt
pause
.NET Core Console App
class Program
{
static void Main(string[] args)
{
Console.WriteLine(args[0]);
if (!File.Exists(args[0])) {
File.Create(args[0]);
}
if(double.TryParse(args[1],out double dbl)) {
Console.WriteLine($"arg[1]={dbl.ToString()}");
}
if (int.TryParse(args[2], out int inte)) {
Console.WriteLine($"arg[2]={inte.ToString()}");
}
Console.ReadLine();
Console.WriteLine("Hello World!");
}
}
So far i tried with 2> for redirecting exception but it creates a 0kb file.
P.S Also i am not sure if i am correctly running the .Net Core Application.I have used:
Source: https://ss64.com/nt/start.html
START "title" [/D path] [options] "command" [parameters] ,
In our case where does dotnet command fit in? You normally start from terminal with dotnet [appname].dll but here you place it after the path and the dll name?
|or>>instead of>?>and>>are pretty similar i didn't want to append..NET Core applicaitonsusingdotnet [name of dll].[name of dll] dotnetinstead. Do parameters need to be preceded by--?