Luanching an exe/bat file when opening a Visual Studio Solution - visual-studio

I've written up a script to do some background loading of a very large multi-project solution folder.
And I've created external tools to launch these scripts manually.
But I need to find a way to automatically launch said scripts with arguments on the launch of this solution. Before everything else loads.
I've tried looking at dozens of answers but they mostly explain just how to set up an external tool and hook it to a keybind, but I need automation.

You can use my Open a file from the solution directory on opening a solution extension for Visual Commander and replace opening a file with launching it.

Related

Need help locating CPP files that were excluded from project in solution explorer

I have been using Visual Studios 2019 as my IDE to learn C++ in school for a little over a month now. I often create new CPP files for practice or class lab work which means I have multiple CPP files in a single solution.
I have learned you can 'exclude' CPP files from the solution to allow you to run other CPP files when testing or debugging a program. However I know this isn't a perfect way to do this because it seems that the IDE will often completely remove the files from the solution explorer leaving me with no way to include them back into the solution.
I have set the solution explorer to list all files and have seen the files stay in the solution explorer with the file name still listed with a little 'do not enter' symbol over the file icon to indicate it is not a part of the solution anymore. This is fine as it allows me to right click and interact with the file at will which in turn allows me to include or exclude the file without issue.
I have had so many different and weird issues when doing this but the question I want answered right now is how can I prevent a CPP file (or any file for that matter) from utterly disappearing out of the solution explorer?
I'd like to suggest a different workflow: create multiple projects within your solution.
Use menu File -> Add -> New Project...
Follow the wizard (likely - Console App), name it as something you can recognize (Lab1, for example).
Now you can select any of your projects in the Solution Explorer and use Set as a Startup Project in the context menu.
This allows you to browse your entire code easily, copy/paste (I don't endorse that :) ), and run/debug the active project.

How use native Windows Explorer instead of built in Intellij file browser

The built in file browser is not easy to used especially in situation where a directory has a lot of subdirectories
Dropping and dragging is unnatural and not productive for me. Why do we need to use 2 tools for 1 job anyway? Isn't Windows Explorer alon already more than capable for that job?
Add ide.win.file.chooser.native=true in Help | Edit Custom Properties and restart the IDE.
Note that you may have various issues with the native file chooser dialog and we don't recommend using it.

Problems of reading and writing files when using Visual Studio to run C++ programs

Recently I'm tring to use Visual Studio to write c++ programs. However, I don't know where to put the input and output files which the program will read. I tried to put the input and output files in the directory ''...\Projects\ConsoleApplication\ConsoleApplication'', which is the same directory with ConsoleApplication.vcxproj file. This works well when I press the start debugging button(F5). However, when I press the start without debugging button(ctrl+F5). The program can't read and write to the files. Can anyone explain what happended?
Generally the files needs to be in the working project environment. Right click on the sidebar and add them to the project. The root directory will work.
You need to give your file path in your programs,
ofstream f1("d:\\me.txt");

Changing the default Source File Directory in Visual Studio

This is not a work-stopper in any way, but I thought I should ask anyway because it is a little annoying. Let's say I create a new project and start putting source files in a directory other than the default that shows up the first time. Afterwords, whenever I open the project, I have to navigate to the source directory once during that session. Like I said, not a big deal (but if solvable, then it's icing on the cake). Quite a few times I absentmindedly put the source file in the default directory and end up committing that file to the SVN and if I am lucky, going through all the files, removing them, then adding them again.
So my question is, is there any way to specify the default source directory on a per project basis?
I have run into the same nuisance. I like to put the public interface header files for a library in a separate directory, but end up with file directory typos because I forget to navigate to the correct directory when saving a new file. Unfortunately, Visual Studio does not offer a setting to change the default directory for new C++ source files.
I had the same problem when I started using build systems (CMake, Premake) which requires me to keep my project files separate from my source files, which hampered my workflow.
Although changing the default source directory seems impossible, if you aren't afraid to spend money, the workaround I found was to use the Visual Assist extension.
You can bind a shortcut of your choise to the Create File command which creates
a new file relative to the directory or your open file.
I'd also recommend to base one's workflow around the wonderful
Create from Usage command (which I think greatly boosts
productivity) which almost eliminates the need to manually create files.
The extension is great, albeit a bit costly. I would love to see Microsoft incorporate these features directly in the IDE eventually as they are found vanilla in a lot of other IDEs e.g. Eclipse, Intellij.
There might be some free extensions available that does the same thing, but I haven't found any.
Changing the Default Project Folder may help. This page demonstrates how to change the default for Visual Studio 2005, and it should be the same for later versions.

How to make file show when opening Visual Studio solution

I need to add a C# solution with examples that would be distributed as part of a software library installer. This solution would have various examples on how to use the product's API.
I want to be able to display a simple "quick start" file explaining how to run the examples when the solution is opened in Visual Studio.
Is there a way to tell Visual Studio to open a specific text file when the solution/project opens?
It sounds like a solution or project template would be the best option. This would let you create an entry in the user's File - New dialog (Similar to 'New Class Library" etc). In VS 2008, these are easier to create - File -> Export Template. The template is just a zip of the project(s) with an xml manifest file you can modify. Part of the manifest schema allows you to specify files to open as HTML or text. The templates can be installed relatively easily as part of a installer package.
Here's more on the general concept:
http://msdn.microsoft.com/en-us/library/6db0hwky.aspx
And schema reference about how to open files in various modes on startup:
http://msdn.microsoft.com/en-us/library/ys81cc94.aspx
If you need to provide more guidance/wizards, consider Guidance Automation Toolkit.
What Will said.
The UI state of the solution (e.g. which files are open for editing) is stored in one of the solution files of which there's supposed to be a separate copy for each user, and which therefore isn't usually checked-in to the shared version control: i.e. not the *.sln file but instead I think the *.suo file (but beware, this is a binary file which won't 'merge').
I don't think it is possible to have a solution file open specific content or even script actions, actually.
Perhaps you could create an MSI setup for your library (if you haven't already) and not deliver a solution with example code, but a project template that is installed by the MSI in the right place to be instantly available as a template in VisualStudio? Then someone can easily do "New Project", select the demonstration template and get a project preset with your example code.
Just make a .bat file (using the VS env) with that calls devenv /useenv yoursolution.sln - this way you can make things a bit fancy if you want to ;)

Resources