Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an asynchronous build event in Visual Studio (2008)?

I am trying to do a poor man integration with xUnit.Net from inside Visual Studio as a post build event.

What I want is when I press Shift+F6 (Build the test project), after a successful build it should run xUnit.Console.exe and output the result in an html file and afterward launch the html file inside the browser.

Below is what I got so far and it work, but not to my liking (in that the browser will appear as a modal dialog of sort and I can't switch back and forward / toggle (using Alt-Tab) between Visual Studio and the browser. Right now I must close the browser for VS to gain focus again which kind of sucks.

My Post Build event below:

"$(SolutionDir)\Components\xUnit.net\xunit.console.exe" "$(TargetPath)" /html "$(TargetDir)result.htm"
"$(TargetDir)result.htm"

Any idea on how to get it so result.htm is displayed inside a browser and not in a modal mode?

After further test, it seems that any shell / command executed ran in modal mode. For example, I tried simple cmd.exe to pop up a Command shell.

I tried using start C:\Windows\IE7\iexplore.exe "$(TargetDir)result.htm" but that didn't work either...

like image 222
Jimmy Chandra Avatar asked Nov 20 '09 04:11

Jimmy Chandra


People also ask

How do I create a post-build event in Visual Studio?

In the Post-build event command line box, specify the syntax of the build event. Add a call statement before all post-build commands that run . bat files. For example, call C:\MyFile.

How do I open a build event in Visual Studio?

Go to Solution Explorer and right-click on the project then select Properties then go to the Build Events tab.

How do I get build command in Visual Studio?

To compile source files from within the Visual Studio IDE, choose the Build command from the Build menu. When you build project files by using the Visual Studio IDE, you can display information about the associated vbc command and its switches in the output window.

How do I debug a post-build event in Visual Studio?

Another way is to check the bin\debug dir for 'PreBuildEvent. bat' or 'PostBuildEvent. bat' which are the file that Visual Studio creates and run during the build events, if there is an error the files remain in the output dir and you can run them manually and spot the error.


1 Answers

This might be a bit round-about, but using Windows power-shell to start the process seems to work. I set the post build event to something like this:

powershell start-process <actual-command-line-to-run>

In this case, Visual Studio regains control immediately, without waiting for the started process to complete.

like image 152
Tarydon Avatar answered Oct 07 '22 23:10

Tarydon