Debug in visual studio using contents of files as command line arguments - visual-studio

I am using visual studio to develop a command line program which takes certain parameters from the command line arguments and its input from the stdin. Currently I am debugging it by setting the parameters manually in project properties as seen in the screenshot:
However I am using a script to generate and compare input, parameters and outputs and I would like to debug the errors, once I have found the appropriate inputs/params/outputs with my script, inside visual studio. Currently I have to manually copy the parameters, I would like to have them read from param.txt which is in the same directory as input.txt which works as an input.

Related

How to make MSBuild print output from a custom tool?

I have a project, which use a .rules file to build some non-c++ sources. How to make MSBuild print diagnostic output from this tool? -- Precisely cerr stream.
(I silently presume, the M$ team have not reached that level of insanity, to give the custom building tools functionality without possibility to print errors from them.)
I've actually noticed you marked question with label visual-studio-2008. I guess it means your custom build tool processes non cpp files in vc2008 project? If so, I think it is not built by msbuild but with vcbuild.
In this case try to add echo on in front of command executed by custom tool.
Vcbuild creates batch files in %temp% that first line contains #echo off and then it is executed. So if you add echo on you should see complete output in output window including command line used for command execution.

debugging with visual studio using redirected standard input

I am debugging c++ console application with Visual studio. I exhausted of inserting the same input every time I debug this program. I would like to use the same input more times.
I do this without debugging in command line with command: Program.exe < 1.in
Is it possible to use debugging with standard input redirected from file???
I already tried looking in to procejt properties. I tried setting Command to $(TargetPath) < 1.in instead of $(TargetPath).
I also tried setting Command Arguments to < 1.in. Niether of these method worked.
I am using Visual Studio 2012. But this is probably same in all versions of studio.
This is a supported debugging scenario. You do have to make sure that the debugger can find the file. Leave the Command setting at $(TargetPath). A possible value for the Command Arguments setting is:
< "$(ProjectDir)test.txt"
if the input file "test.txt" is located in the project directory. Or type the full path of the file to be sure. The MSDN article that describes this feature is available here.
I just create a file called stdin.txt in the project
1) set the Build Action to Content
2) Copy to Ouput Directory: Copy if newer
Then when you build stdin.txt is copied to the same folder as the executable.
Then in project properties debug|command line arguements enter the following
< stdin.txt
There is no need to use a path macro
If you don't want to mess with the the path you can add a new file with a right click on the source files folder in the solution explorer and then paste to it the content from the wanted file. And then change the command argument to the new file name.

Possible to Auto Open file in Visual Studio

I currently use the following cleartool command using Visual Studios External tool interface:
Command: \installationpath\cleartool.exe
Arguments: annotate -nheader $(ItemPath)
Initial directory: $(ItemDir)
I do use the output window. Which will let that command print out the location of the .ann file it produces. I'm wondering if there is a way for Visual studio to auto open that produced file?
In this case its not a huge hardship to copy the location and open the file. I'm just always looking for ways to make things easier.
Using just one external tool, you wouldn't be able to execute cleartool, and to open a file (generated from the cleartool command).
You can open a file from a Visual Studio External Tool as explained here, but that wouldn't execute cleartool.
So I would recommend executing a script (.bat, .cmd, .vbs) in order to:
do the cleartool command you want
open the generated file.
You would pass to this script no only $(ItemPath), but also, depending on where it is generated, $(ItemDir), or $(ProjectDir), or $(SolutionDir), or $(TargetDir).

how to debug VC++ program, input file not open while debuging

i am using Visual studio 8. i pass command line argument to my program when i execute the program using exe file it works fine but when i use to debugg. it is unable to open the input file which i have given it in the form of command line argument. although i have given the command line argument in the Project->properties->debug->command line arguments....
e.g
"program.exe" input_file output_file
input file contains data which i have to use in the calculation if i am unable to debug it. how can i remove the errors in my program
reply me
thanks
You may need to specify the working directory on that same property page in order to have your debug executable run in the same directory as your input file. Right now it's probably not able to pass your file because it can't find it.
You should not include "program.exe" in the command line arguments.

How to pass the assembly name as a command-line argument when debugging

I have an NUnit test assembly (a .NET DLL). When I click Run in Visual Studio I want it to launch NUnit and run the tests in this assembly. I can do all of that.
Instead of specifying the full assembly name and path in the command line arguments, does Visual Studio support some sort of macro that expands into that for the Command Line Arguments box? Most other development tools I have used support this, but I cannot find anything in the documentation about this.
I was expecting something like: %assembly_full_path%
The reason I want to do this is so if the assembly name or build location changes, then I don't have to update the command line arguments as well.
This doesn't work as far as I can tell. Macros in the Command Line arguments box do not get expanded. Not even environment variables. Bummer.
A workaround is to create a custom tool. Tools + External Tools, Add. Title = Run tests, Command = nunit.exe, Arguments = $(TargetPath), Initial Directory = $(TargetDir). Tweak as needed. You could assign a keystroke to this new tool command, even F5.
Using VS2005, the only item I need to provide in the Command Line Arguments is the name of the dll. I suspect VS sets the default working directory to the project's output directory, as I've never specified the path and yet the tests always load correctly.

Resources