Run console app in visual studio when file changes - visual-studio

Is there a way in visual studio (2015) that when a file is changed i can exec a console app and pass the updated file name as an argument into the console app?

Do you really want to run your tool every time when the file changes?
Would you compromise to run it as a part of your build? Then you can do it easily.
In the Properties of that file, General - change "Exclude From Build" to "No". On the same page, change "Item Type" to "Custom Build Tool".
The "Custom Build Tool" item will be added to your "Configuration Properties" tree. Click on "General".
Specify the "Command Line", something like:
notepad.exe %(FullPath)
Also specify the "Outputs", like:
$(OutDir)
If you really need to run your tool on every save, you'd need to write a Visual Studio extension, handle "save" notification and run your tool from there.

You can subscribe to the DTE.Events.DocumentSaved VS event and run your console app from it. For example, adjust the following Visual Commander extension: Run Cppcheck on the saved file.

Related

Prevent "Open Project" Dialog from showing

In last versions of Visual Studio IDE, if I open it without specifying a ".sln" or ".vbproj" file as parameter, it immediately opens a "Open Project" dialog. But most of times I do this, that's because I want to start a new project. Can I prevent "Open Project" dialog from showing on VS IDE Startup?
Sounds like you need to change your Visual Studio Startup options. Click Tools->Options. Under Environment, select Startup. Change the At Startup option:

How to add a pre-build step to project via the Visual Studio IDE

Is there an easy way to add a pre-build/post-build step to a project via the Visual Studio IDE? I know I can edit the .csproj/.*proj file - what I want to know is if there is a way right from the IDE.
You can right-clic on the project name in the solution explorer and clic on "properties" in the popup menu. In the window that shows up, go to the section "configuration properties / Buid events" (or something similar: my IDE is in french). You will then have the choice:
Pre-build events,
Pre-link events,
Post-build events.

Moving from Visual Studio to Sublime Text

I'm working with Sublime Text for a while now and it works perfectly! But at my new work they're using Visual Studio, with some plugins and shortcut changes I'm now be able to work a little bit faster but I prefer Sublime Text.
Why I'm stuck to Visual Studio at my work is because of 3 things:
1. TFS: Team Foundation Server
I've found the Sublime TFS plugin, I haven't tested it yet but I think it works the same as the Sublime SVN plugin which I don't like (no status on checkout, just waiting until it's done). For SVN I'm using TortoiseSVN which works nicely. Is there something like TortoiseSVN for TFS?
2. Solutions
If I browse to the solution/product folder on my computer, add a new file and go back to Visual Studio I've to include that file into the solution/project. I'm used to exclude files which I don't like to use in my project instead of include. Is it possible to change this?
3. Build system
After every change I've to build. Instead of just save (F5) and go to my browser (ALT-TAB) which refreshes automatically after every change, I have to save (F5), build (SHIFT-F6), go to my browser (ALT-TAB) and refresh (F5) with Visual Studio. I'm pretty handy with it now, but I think this can be done easier. So is it possible to build automatically after saving?
What I did until now is searching on Google. I've found some interesting things but nothing which covers these 3 things. For example; here a simple tutorial for the build system. I hope someone can help me out with this so I can say good bye to Visual Studio and return to Sublime Text with love.
I have setup a shortcut key in Visual Studio to open my files in Sublime Text Editor. Below is a step by step guide to doing this.
Step 1:
Open Visual Studio, Go to "Tools" menu and Select "External Tools..."
Step 2:
Click on "Add". Set up a Title say "Open in Sublime" , browse to "sublime_text.exe" to the set the Command textbox. For the arguments fill them with $(ItemPath):$(CurLine):$(CurCol) - this will tell Sublime to open the Visual Studio's current file and go to the same location within that file. Set the Initial Directory to $(ItemDir).
Step 3:
Now if you go Menu > Tools you will find our newly added "Open In Sublime" option. Now let's take this one step forward and setup a shortcut key for this.
Step 4:
Go to Menu > Tools > Options, Under Environment select "Keyboard". In the "Show command containing:" field search for "externalcommand6" and press in your shortcut key combination you want to assing and click the "Assign" button. Avoid combinations that are already in use.
That's it you're done
Sublime text editing is now just a keystroke away.
You can use them both. Visual studio is an ide and manages a lot more then just editing the text files.
If you want to use your text editor of choice you just need to get familure with the command line tools that VS hides from you.
For TFS tasks you need to use TF
When you need to build just invoke MSbuild which is what Visual Studio more or less does anyway. You can also edit the project files by hand as there just msbuild files.

Is there a Visual Studio option or add-on to add an "Open Explorer Here" when I right click on a project in the solution folder?

When I right click on a project in the solution explorer I'd like to be able to select an option that would open a new windows "Explorer" that lists the contents of the build directory. I'd settle for the project directory... but getting me into /bin/x86/Debug vs /bin/x86/Release based on the active build configuration would be major bonus.
I find myself manually navigating to that folder fairly often for various reasons - usually on Utility applications which don't have installers / cmd line build scripts etc
I currently use 2005 express. But, am open to upgrading.
A couple things that might be close enough:
add an "external tool" to the Tools menu. In the "Tools | External Tools..." dialog:
Click "Add" and give the new tool whatever name you want
Command: %systemroot%\system32\cmd.exe
Argument: /k "c:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86
Initial directory: $(TargetDir) // (or whatever appropriate macro)
Right click on a open document's tab and select "Open containing folder"
My VS 2005 Standard IDE already had a "Visual Studio 2005 Command Prompt" tool, but it landed the command window in the VC installation directory. Changing the "Argument" and "Initial directory" fields as above made it land in the project's target directory.
The drawbacks are they don't show up in the right menu for the project and they might not land you exactly where you want, but they should land you pretty close.
No sure this is what you want but the "Open file" icon will pop up a FileOpen dialog in the project folder. From there you can right click the Release or Debug folders to open them in an Explorer (and Cancel the dialog).

Output path for build in visual studio 2010

I need to output the project dll in program files. "$(PROGRAMFILES)\Microsoft..." It is not building in program files, but in the project itself in a folder called "$(PROGRAMFILES)"!
How do I build in program files??
In Solution Explorer, right click your project, click "Unload Project"
After the project unloads, right click on it again, click "Edit MYPROJECT.csproj"
In the XML editor window that opens, change <OutputPath> elements to <OutputPath>$(ProgramFiles)</OutputPath> -- either all of them, or only those for the configurations that interest you
Save and close
Right click on project again, choose "Reload Project"
Done!
And if you just made a new environment variable, reload visual studio as well, else it will use 'C:\' instead of your variable content.
This sounds like a good case for a post-build event that copies the project output to the folder you want:
copy $(TargetPath) $(PROGRAMFILES)\Microsoft...
right click on project select properties. Select Build tab you have output section
In output path give the specific path for you program file/microsoft. This should work. I Tested it.
You need to open the csproj file in a text editor and manually enter your environment variables in the OutputPath section. Visual Studio escapes the '$', '(' and ')' when you try to do this from the IDE.

Resources