如何在Visual Studio(2008)中创建异步生成事件? [英] How to create an asynchronous build event in Visual Studio (2008)?

查看:87
本文介绍了如何在Visual Studio(2008)中创建异步生成事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Visual Studio内部将xUnit.Net与可怜的人集成在一起,作为发布后的事件.

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

我想要的是当我按Shift + F6(构建测试项目)时,构建成功后应运行xUnit.Console.exe并将结果输出到html文件中,然后在浏览器中启动html文件.

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.

以下是我到目前为止所能得到的,并且可以正常工作,但是不符合我的喜好(因为浏览器将显示为排序的模式对话框,并且我无法在前进和后退之间切换(使用Alt-Tab键) Visual Studio和浏览器.现在,我必须关闭浏览器以使VS再次获得焦点,这很糟糕.

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"

关于如何获取它的任何想法,以便result.htm显示在浏览器内部而不是以模式方式显示吗?

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

经过进一步测试,似乎所有执行的shell/命令都以模式模式运行.例如,我尝试使用简单的cmd.exe弹出Command Shell.

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.

我尝试使用启动C:\ Windows \ IE7 \ iexplore.exe"$(TargetDir)result.htm",但这也不起作用...

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

推荐答案

这可能有点麻烦,但是使用Windows power-shell启动该过程似乎可行.我将构建后事件设置为这样:

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>

在这种情况下,Visual Studio立即重新获得控制权,而无需等待启动过程完成.

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

这篇关于如何在Visual Studio(2008)中创建异步生成事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆