Search code examples
visual-studio-2008build-process

Can I send error from console application that is called by post-build event in Visual Studio?


Because I set post-build event in ASP.net Web Application project to run the following command line.

start $(SolutionDir)[PathToMyApplicationInSameSolution] [some parameter]

So I need to send some error from console application to Visual Studio for showing Build Error(Like Visual Studio Build Error)

Thanks


So I change post-build event command to the following command.

$(SolutionDir)[PathToMyApplicationInSameSolution] [some parameter]

And then, I edit my main function to display error. I can't see anything in Error List in Visual Studio. I see only in Output only. Do you know how to display error like build error that is generated by Visual Studio?

[STAThread]
static void Main(string[] args)
{
    Console.Error.WriteLine("Test Error");
    Console.WriteLine("test error");
}

Thanks

Ps. Because I new to use command application, So I forgot that start like create new thread for console application.


Solution

  • I found the solution to solve this problem. Visual studio will detect some pattern of output to be reported as error. So, I don't need to change default main method interface to return int(But you can use return value to identify error publicly).

    More info : MSBuild / Visual Studio aware error messages and message formats