开发者

How can I get Visual Studio to use /RunExit and provide my programs command line arguments?

I have a solution file for a command line executable. I want to run my executable, with different inputs, through the debugger without my interaction, while also setting its output to a log file.

For example, this is sort of what I want:

devenv /DebugExe "myprogram.exe" "my inputs"

That loads VS and automatically sets my programs inputs. However, I want to do this over and over with different inputs to my program and mine the output files later. So the closest I've figured out, but doesn't work, is this:

devenv /RunExit "myprogram.exe" "my input set" /Out out1.log
devenv /RunExit "myprogram.exe" "a different inp开发者_如何学Pythonut set" /Out out2.log
...

Is there any way to do this? Again, the important part is that I could queue up a bunch of runs and mine the output files later for their output.


While I did find a way to do what I want, I don't like it. So I'll wait a while before marking my own answer as accepted.

What I really needed and wanted was what I stated in my question:

devenv /RunExit sln "input args" /Out out.log

The problem is that VS doesn't allow this, "input args" is invalid - unlike if you were to use say /DebugExe but then there is manual work involved again and that didn't help me. So in the script I'm using to call devenv dynamically, I used a regex to replace the "Arguments = " line in the sln file with the appropriate arguments each time. Then this command line works:

devenv /RunExit sln /Out out%x%.log

Each call the sln is modified to contain the new set of args and so each run, I'll get different output in my out%x%.log file (which I name differently each run so I can keep track of which log file went to which inputs). Thanks everybody for watching.


I wanted to do something similar: in my case one of my parameters was a file system path, which could contain a space, which would have to be quoted, inside the string in the batch file which must be quoted. I enhanced my command line executable's code to also look at environment variables (Environment.GetEnvironmentVariable) in addition to the command line parameters to it. Then just set the specific environment variable value prior to each invocation of devenv.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜