I have a .js file that normally gets executed by cscript.exe
(i.e. is not run in the browser and cannot be run there).
I know, that I can feed cscript.exe
the //X
parameter in order to get asked for a debugger to choose. Ok. That's fine.
I select "Visual Studio 2005 Debugger", IDE es up, execution stops on the first line. Fine.
Script terminates (or I terminate it), I edit something and want to debug it again.
Simple thought would be just to hit F5 and run the debugger again. But this doesn't work. VS just tells me that it couldn't find any debugging symbols in cscript.exe
:
What now? Starting cscript.exe
from the mand line again for each debug run is quite cumbersome in my opinion.
Is there a way to simply debug the script with VS? Also hints for other debugging tools would be appreciated.
Edit:
The answer of t0nyh0 is pretty close. I create a dummy console application, pile and the debugger es up. However, two things are not perfect
cscript.exe
always asks for the debugger to use (which instance of VS).
Could this be overe by specifying a certain debugger instance directly in the mand line?In order to fire a post-build event, there have to be some modifications in the sources. Currently, I simply add/delete a blank line to trigger building of my dummy project.
Is there a way to always execute the post-build script, even if nothing has changed?
I have a .js file that normally gets executed by cscript.exe
(i.e. is not run in the browser and cannot be run there).
I know, that I can feed cscript.exe
the //X
parameter in order to get asked for a debugger to choose. Ok. That's fine.
I select "Visual Studio 2005 Debugger", IDE es up, execution stops on the first line. Fine.
Script terminates (or I terminate it), I edit something and want to debug it again.
Simple thought would be just to hit F5 and run the debugger again. But this doesn't work. VS just tells me that it couldn't find any debugging symbols in cscript.exe
:
What now? Starting cscript.exe
from the mand line again for each debug run is quite cumbersome in my opinion.
Is there a way to simply debug the script with VS? Also hints for other debugging tools would be appreciated.
Edit:
The answer of t0nyh0 is pretty close. I create a dummy console application, pile and the debugger es up. However, two things are not perfect
cscript.exe
always asks for the debugger to use (which instance of VS).
Could this be overe by specifying a certain debugger instance directly in the mand line?In order to fire a post-build event, there have to be some modifications in the sources. Currently, I simply add/delete a blank line to trigger building of my dummy project.
Is there a way to always execute the post-build script, even if nothing has changed?
- With regards to 2. on the Build Events tab in Visual Studio, you have different options when to run Post Build events. At least in VS 2010, your options are "Always", "On successful build" and "When the build updates the project output". Not sure if it's the same for 2005 or not. – BryanJ Commented Mar 16, 2012 at 11:31
4 Answers
Reset to default 2 +100There might not be a way to attach the debugger to cscript.exe
itself, but you may be able to create a post-build event that runs a batch file that executes the cscript.exe //x myScript.js
mand so that every time you build, it executes for you automatically.
See this for more information on post-build events: http://msdn.microsoft./en-us/library/ke5z92ks(v=vs.80).aspx
While not a debugger tool, you should consider using a JavaScript testing framework for Visual Studio, such as Chutzpah, which will most likely make your life a lot easier.
Along with standard browser debugging tools (Firebug or Chrome Inspector), I've found that's all I usually need to build clean, tested, mostly-bug-free JavaScript code.
I don't have cscript at hand, but I think you can try to attach VS to the process manually.
After you start up your js using cscript.exe //x myScript.js
, click "Debug - Attach to Process", find your cscript.exe process and attach to it.
I forget if VS2005 has this function but VS2008 and VS2010 do.
It is the native debug action that VS takes to debug (attach to the running process). If this doesn't work, I don't think you can do this using Visual Studio.
Best Javascript Debugger is Rhino Debugger See http://www.mozilla/rhino/debugger.html . it is open source and you can get the source code of the Debugger GUI. you can customise it as you wish :-) .