How to open a file using Visual Studio debugger commands - visual-studio

Is it possible to open a file using debugger commands options of Visual Studio?
For example I want to run my program (with some command arguments) and then open a file.
The cmd equivalent would be:
app.exe args & file.png
Can I do the same thing in visual studio using projects settings or any other way?

You can use dev command prompt inside Visual Studio to achieve the same result
You can open Developer Command Prompt from Tools > Command Line menu
Then just type in whatever command you use in cmd

Related

Open Visual Studio Dev prompt and enter sequence of commands

I want to use PowerShell to run a script that:
Launches Visual Studio Developer Command Prompt (VS 2017)
Enters in sequence of commands to do a batch and release build
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat" && <next sequence of commands to do batch build>
The above code simultaneously opens VS Dev prompt and my sequence of commands. There is no pause after opening the prompt, so the commands do not run.
Screenshot of what happens

Configuring cl CMD compiling Windows

I have already read on MSDN.com that to enable command line compilation through the cl command you have to run the vcvarsall.bat file. I have run this file in CMD and compiled code using the cl command. The issue is that after I leave the CMD and reopen it, I no longer have the ability to use cl and have to rerun vcvarsall.bat every time I reopen CMD. Is there any way to avoid having to do this? Thanks.
Just create a shortcut on your desktop that calls
cmd /k "%VS140COMNTOOLS%\vsvars32.bat"
Adapt the environment variable and batch file name to fit your installed VS version number. In the example above, this will work with Visual Studio 2015.

Change directory in visual studio command prompt

I want to know what is the command I should execute in the command window of the visual studio 2013, to change directory to:
C/:Users/user/Documents/Visual Studio 2013/Projects/OutlookAddin/publish/<Most_Recent_Version>/OutlookAddin_TemporaryKey.pfx
What is the command I must execute?
Actually, cd cmd works, but in a bit diff like this:
syntax:
cd /d c: or e: etc..
where /d stands for drive
for instance:
cd /d C/:Users/user/Documents/Visual Studio 2013/Projects/OutlookAddin/publish//OutlookAddin_TemporaryKey.pfx
No need for the single or double quote in this case.
Now to execute any type of files for instance simply add '.\' before the executed one.
syntax:
.\OutlookAddin_TemporaryKey.pfx or .\example.exe what so ever
cd does work. However, keep in mind that if the path you're trying to get to has spaces, you need quotes around it (the path). E.g.:
cd "C:\Program Files\Microsoft Visual Studio 10.0" Also, note that the
"Visual Studio command prompt" that is mentioned in Step 6 is not the
"Visual Studio Command Window" - I think this is where the problem
comes from. The command prompt is a separate executable that you can
start by clicking Start, point to All Programs, point to Microsoft
Visual Studio, point to Visual Studio Tools, and then click Visual
Studio Command Prompt. Alternatively, just search "Visual Studio" in
the search bar in the Start menu, and it should show up
Source: Using the Command Window in Visual Studio
First create a file on CMD (COMMAND PROMPT)
1.cd desktop
2.mkdir filename
3.cd filename
4. code .
(It has to be a space between code and the dot to open up the file in visual studio code)
Note: If you just want to open visual studio, then go to CMD and just type in 'code' without the dot.

How to avoid prompt when opening gVim as external tool from Visual Studio?

I am trying to set up gVim 7.3 as an external tool to edit text from Visual Studio 2010.
Here is my argument list:
--servername VimStudio --remote-silent +"runtime visualstudioinvoke.vim" +"call cursor($(CurLine), $(CurCol))" "$(ItemFileName)$(ItemExt)"
Everything works, but when I launch gVim as an external tool gVim requires me to
Press ENTER or type command to continue
Though this is not very burdensome, I would prefer to just have my cursor positioned and immediately ready to go.
I find that if I remove +"runtime visualstudioinvoke.vim" from the argument list and remove set ruler from my _vimrc file I can launch gVim as an external tool without the prompt. My visualstudioinvoke.vim file just contains the single line :
normal zz
Is there a way to get gVim to launch from Visual Studio 2010 with my desired options without having to first press enter to get rid of the prompt?

Use Console2 for Visual Studio debugging?

Is there a way to use the popular Console2 cmd.exe replacement for Visual Studio debugging? In other words, when I debug a console app under VS, I want it to use Console2 instead of cmd.exe.
Interesting question. I looked into it, there are some options but none are pretty.
Console.exe takes arguments, so it's possible to start it with a specific tab and execute an arbitrary process. However, this process will always be run within it's own cmd.exe; for example if your program is c:\my.exe and you launch Console as console.exe -t tabname -r c:\myexe Console2 internally calls CreateProcess( ... cmd.exe c:\my.exe ... ), as a result you can't even see the output of my.exe. This is easily solved though: launch it as console.exe -t tabname -r "/k c:\myexe": the /k switch makes the cmd.exe stay active and you can see your program's standard output. (I looked through the source but couldn't find a way to 'attach' a tab to a currently running Console instance, so launching with arguments will always create a new instance, not sure this is what you are looking for?
You can easily modify the project's debugging properties to reflect the above:
Command: /path/to/console.exe
Command Arguments: -t tabname -r "/k $(TargetPath)"
When starting your exe from within VS, it will launch your exe witin a Console session. However the debugging won't work as VS will try to debug console.exe, not my.exe since that is now a different process. Putting a DebugBreak(); as first line in your exe's main() will sort of solve this, as it will present you the option to debug your exe. All in all, this may a bit too much of a hassle to achieve what you want, but i don't think there's another way: Console always spawns a new process, so the only way to get it debugged is to attach the debugger to it after that process started.
Scott Hanselman blogged about this.
He suggests using this value for Console Settings > tabs > Main > Shell :
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
Sadly for me, This does not appear to work for Visual Studio Express 2010, which lacks a vcvarsall.bat file.

Resources