As with most other versioning systems some brilliant individual, or group thereof, has established an extention to Visual Studio so that a developer may manage the state of their files directly with the application they work most often in.
Sadly, MKS doesn't really have that kind of Open-Source following, nor does the user base of the application weigh heavily with the developers out there.
I'm kind of setting myself up for an answer here, but it was a refreshing note here in the office when my coworker opened this can of worms...turned out many of our developers already had some of these in their personal toolboxes...these are some of the commands we came up with.
To start, there is a rather easy way to add custom tools to the menus in Visual Studio :
Tools --> External Tools
This dialog is pretty much a wizard to set up quick command line options in the application that you can later refer to when adding a menu option to a tool bar or flyout.
Note that the order of the list of Menu Contents will be crucial in figuring out which item in Visual Studio to add to your menu/toolbar. For instance ::
When you access your Tool Customization dialog, the Command will be listed under Category 'Tools' and will be enumerated with the following format :: 'External Command XX' where XX is the number corresponding to the position of your command in the list.
(eg MKS-AddMember would be 'External Command 3')
OK...now that that's behind us, let me list out a few different MKS commands that translated well for us. These will act as the Arguments in the External Tools dialog...
These can all be run from your command line prompt. The executable is (usually) at C:\Program Files (x86)\Integrity\IntegrityClient10\bin\si.exe
Checkout Member :: co -g --sandbox="$(ItemDir)\project.pj" "$(ItemPath)"
Add Member :: add -g --createSubprojects --sandbox="$(ItemDir)\project.pj" "$(ItemPath)"
View History :: viewhistory -g --sandbox=”$(ItemDir)\project.pj” “$(ItemPath)”
Diff Two Files :: difffiles -g “$(ItemPath)”
Revert :: revert -g --sandbox="$(ItemDir)\project.pj" "$(ItemPath)"
You can also get creative and find other commands by running “si -?” from a command line.
Post more findings here of things you find useful!
As a follow on to beauXjames' answer, I found it useful to add these commands to the context menu in the Solution Explorer:
Tools->Customize->Commands tab->Context menu:“Project and Solution Context Menus | Item”
Add New Menu (i.e. MKS)
Reselect that new menu from the drop down
Add your ExternalCommand1,2,3… to that
Related
Summary: Is there an easy way to save alternate command arguments used by the Visual Studio debugger?
Details:
Visual Studio has an option to set Command Argument that are used by the debugger. For example in the screenshot shown here I've set them to FOO BAR. Sometimes when debugging a project I want to switch the arguments to test different input sets. And often the arguments are much longer than just FOO BAR. It would be nice if there was a way to save the arguments that I've typed and switch between them quickly. Ideally it would also be possible to change the working directory at the same time. But I haven't found a way to do this yet so that's why I'm asking here. I'm using Visual Studio Professional 2012.
You can just create new configuration(s) for this project. I see that your current active configuration is Debug (top left corner of project settings dialog). You can create new configuration(s), which will be based on this one, and name them like Debug-Test1, Debug-Test2, etc. After you will do this you will have a choice to switch between this configurations in VS Debug Toolbar.
What I would like
I would like to easily run a batch file without leaving Visual Studio. The batch files are not always the same, they change depending on the solution I'm working with.
What I know so far
I know you can create custom shortcuts in the Tools section of Visual Studio (Under External Tools).
My solutions have various scripts/batch files and I wish there was a way to create shortcuts under a solution folder or some other place that is solution specific.
I can create the scripts but there doesn't seem to be a way to run the script. I don't like having to open Windows Explorer each time I want to run a script.
Perhaps an add-in that would start a process with the selected file in the solution explorer? Or something similar?
Here is a full steps on how to add the external tool to run the batch files by right click on the file and select "Run the batch file", also whenever you need to edit the file, just open and edit it.
Here's how to do it...
Create an external tool called "Run batch file"
1) From Tools-> External Tools, create a new and put the below parameters:
2) Set the Command to: CMD.EXE
3) Set the Arguments to: /c "$(ItemPath)"
4) Set the Initial directory to: $(ItemDir)
5) ![DO NOT Check the "use output window" check box and then Apply to create the command
Note where the new command appeared in the list of commands.
The external commands are numbered from 1 starting below the divider bar.
#1 is usually "Create GUID"
To make it easy to remember you can move the new command to the top, to be the number one command in the list.][1]
6) Now go to Tools -> Customize and select the commands tab.
7) Select the Context menu radio button and select "Project and Solution Context menus | Item" from the drop down.
8) Now use "Add Command..." to add a new command
9) In the Categories list select "Tools"
10) From the commands select the "External Command #" that corresponds to the position of the "Run Batch file" custom command you noted the number of in step 5 above.
11) Move it to the right position in the list add keyboard short cuts etc.
12) Close the dialogue.
Now right click on the batch file and you should see a "Run batch file" menu item. This will execute th batch file and show it's output in the VS Output window.
Hope it helps.
I did this by right clicking the batch file and choosing "Open With", then I added a new editor and used explorer.exe (and then set that to be the default editor).
The best way to proceed is to write an external tool, and then you can pass in parameters based on your current solution that is loaded.
There are many project and solution specific variables you can pass to your external tool.
Open up the 'External Tools' dialog, and select your tool in the list box.
You will see the title of your external tool, as well as the command that points to the script or batch script you want to call.
The arguments edit box has a button next to it with an arrow next to it. Click the arrow and you will see a big list of variables, or parameters, you can pass to your external tool.
So, for instance you can use the following:
$(ProjectDir) - The full path directory of the project you are working on.
for instance "C:\builds\myproject"
$(ProjectPath) - The full path name of the vcproj you are working on.
for instance "C:\builds\myproject\foo.vcproj"
$(ProjectName) - The name of the project.
for instance "foo"
$(SolutionDir) - The full path directory of the solution that is currently loaded.
for instance "C:\builds\mysolution"
etc...
Will the Build Event hooks (pre-build, pre-link, post-build) be of any use to you? Also you can check out the Custom build setup too. Those are part of the solution.
You can add a new Makefile project to your solution. A Makefile project is a simple Visual Studio project whose build action is any command line you want. It is listed under the Visual C++ - General category in the new project dialog. In your case, just set the build command to invoke your batch script. Then, to execute your script while working in your solution, just right click on the Makefile project in the Solution Explorer and choose the Build context menu item.
Since you intend to run this script run on-demand (as opposed to running each time you build) you will want to remove it from the build in the Configuration Manager. Don't forget to disable building the project for all platforms and configurations.
Most of the macros are available to the Makefile project's build command line, although perhaps some that are associated with your main project will not have the correct value.
On my environment (Visual Studio 2022 v17.3.6 on Windows 11 v21H2) the $(ItemPath) parameter for cmd.exe leads to an error, but it works properly without:
This seems reasonable to me as the command is called "Open With" and works like the Windows "Open With" command by autmatically passing the file as an argument.
In Visual Studio you can add an external tool and pass it the selected text as parameter.
Does eclipse have the same kind of feature or are one obliged to code a plugin for that ?
If so, any specific code sample to do just that because all I found is general sample plugin for custom editor.
In the menu, go to : Run > External Tools > External Tools Configuration.
This will open a dialog in which you can create external tools configuration (to execute external programs from Eclipse) :
(source: pascal-martin.fr)
At the bottom of the dialog, there is a region for "Arguments", and a button called "Variables". If you click on this one, you have a liste of variables you can use.
Of of those is "selected_text", which "Returns the text currently selected in the active editor." :
(source: pascal-martin.fr)
This should allow you to launch pretty much whatever program you want/need, directly from Eclipse, without having to create any plugin ;-)
ONly thing is those programs will not be quite well integrated in Eclipse -- but still usefull !
Sure, they are even called "External Tools". look in Run->External Tools.
Actually, start by typing "External Tools" into the Eclipse Help search box.
Eclipse has the kitchen sink, do you think they would leave this out? :-)
As a side note might be added, that the possibility to add external tools was one of the key features of the eclipse platform once it was brought up back in the days. VisualAge had a big problem with external tools.
Is it possible to run a batch file as a menu item in studio 2008?
Yes, go to Tools | External Tools in the menus and add your batch file as the Command. You can also pass in any arguments that you want such as the build target, project directories, etc.
Once you do this, your batch file will appear as one of the items on your tools menu. If you want, you can then add a toolbar button for it by going Tools | Customize | Tools and dragging the External Command # that matches your tool to the toolbar. You will then want to change it to an icon and select an image for it.
The tools are numbered 1 based in the order they appear in the menu.
Run batch files in VS Solution Explorer directly
This is much better than having external tool since you can execute a batch file simply by double clicking on it in solution explorer just as if you were opening a code file. I've written a blog post about it that will help you lots to configure it and of course use it.
A sidenote
You've asked this question 2 years ago, but I see that nobody mentioned this technique so I'm providing this answer for any future reference. I hope it gets upvoted, so it will be near the top for readers to see.
Use "Tools"/"External Tools..." menu item and add your bat-file to "Tools" menu
As A refinement to the given answer:
Say your project/solution have several BAT that are project specific - you wouldn't want to run one from another project - that's what could happen with the above answer - because you have hard wired the path to the bat.
Just set up one external tool nameed "Run BAT", sets its Command to $(ItemPath), and set the initial directory to $(ItemDirectory), The dialog will whinge that this is not a real executable - but ignore that.
Tie the tool to a button if you want.
Now to run the BAT of choice from the project or solution - just open the .bat for editing and select the "Run BAT" external tool.
you could also set the "use output" option as well and the bats output will be in the output window.
Unfortunately it looks like for various reasons I'm going to have to use Visual Studio 6 instead of a newer version of VS.
It's been a long time since I've used it. I'm looking through its menus and don't see any obvious way to set up any custom build steps (pre-build, post-build, pre-link... anything would help actually).
Can anyone give me instructions on how to set up steps like this?
Open your project, then open the Project Settings screen (Project → Settings or ALT-F7). Alternatively, right click on a file in the FileView and select Settings.
From the Project Settings screen, go to the General tab and check "Always use custom build step". This means that the file you just chose will be an input file for a custom build step. From the "Custom Build" tab you can then give the commands to run and specify what files will be generated.
For pre-link, post-build and such, select an executable (or library) from the Project Settings screen. Then use the little arrow button to scroll to the rightmost tabs. From there you'll find the Pre-link and Post-build steps.
It's quite simple, really, I'm sure this is enough to get you started.