... so I was reading along in this book ...
"ASP.NET ships with a tool (that) you can easily call from within a Visual Studio Command Prompt window. ... you should launch the tool from a Visual Studio Command Prompt window, as it includes the necessary path information to the .NET Framework directory containing the necessary tools."
Visual Studio Command Prompt window??? There was no explanation about that in the book. (Don't you just hate that!)
First, you don't have to tell me about DOS. That was my first PC OS. In fact, it was the first five or six. I was one of those, "Oh Wow! Windows is cool because there is this thing called a mouse!" But I didn't know that there was a Command Prompt window already in Visual Studio. So I fired it up and started looking.
There is a window called, "Command Window" under the View > Other Windows menu. That isn't it. Intellisense works a treat in that window, but all you can execute are VS things. As the doc says, "commands or aliases directly in the Visual Studio integrated development environment (IDE)." No, in fact, what you have to do is (again quoting the online doc), "Click Start, point to All Programs, point to Microsoft Visual Studio, point to Visual Studio Tools, and then click Visual Studio Command Prompt."
I'm like, that's marvelous! ... It's easier to start DOS by entering "cmd" in the Start button Run box.
Let's look at the "Visual Studio Command Prompt" in more detail. It appears to just set the path for you and put you in (Ta Da!) the VC directory under Visual Studio. Not even the C# directory and certainly not the VB directory. I guess they assume that anyone who uses this tool is really hard core and programs directly against the hard drive with a magnifying glass and a magnet.
What it actually does is run this DOS command. (In my case.)
%comspec% /k ""C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
What does vcvarsall.bat do? Well, it sets the target compiler environment so you can compile code for a different processor. Like I said, "hard core".
You can find other pages where they just tell you to use that command string and don't tell you what it means. I suspect that they just copied it from the shortcut Properties and didn't bother to figure it out. %comspec% and /k are OK. %comspec% just points to the directory where DOS ... uhhh ... "the Command emulator" ... is and /k just keeps a secondary session active so the window doesn't close. I also recommend Prompt $P to add the path to the command prompt. But x86 targets the Intel 32 bit compiler, which is fine for most of us. But what if you're using an AMD64 processor (one of the other choices). I don't know if the Visual Studio install is smart enough to change that argument automatically or if you just get the wrong target. More to the point, why do they assume that this is what you want to do in the first place?
Without further ado, here's how to make a tool that you can call up from inside the Visual Studio environment.
- Select Tools > External Tools in Visual Studio. Click the Add button.
- Fill in the Title. (I called mine DOS. Yeah, yeah, yeah. I know it's not really DOS.)
- Enter cmd.exe in the Command textbox.
- Enter %comspec% /k Prompt $P in the Arguments textbox.
- Pick an Initial directory. I use $(ProjectDir).
- Click Apply and OK and you're ready to roll.