Possible to Auto Open file in Visual Studio - visual-studio-2010

I currently use the following cleartool command using Visual Studios External tool interface:
Command: \installationpath\cleartool.exe
Arguments: annotate -nheader $(ItemPath)
Initial directory: $(ItemDir)
I do use the output window. Which will let that command print out the location of the .ann file it produces. I'm wondering if there is a way for Visual studio to auto open that produced file?
In this case its not a huge hardship to copy the location and open the file. I'm just always looking for ways to make things easier.

Using just one external tool, you wouldn't be able to execute cleartool, and to open a file (generated from the cleartool command).
You can open a file from a Visual Studio External Tool as explained here, but that wouldn't execute cleartool.
So I would recommend executing a script (.bat, .cmd, .vbs) in order to:
do the cleartool command you want
open the generated file.
You would pass to this script no only $(ItemPath), but also, depending on where it is generated, $(ItemDir), or $(ProjectDir), or $(SolutionDir), or $(TargetDir).

Related

code command using ssh-remote pluguin using bash

Is there a way to open the visual studio code using "code" command on linux terminal but opening it with a specific ssh folder.
On documentation i have read that you can open an specific path with code command but what i want to know if this is also possible with an ssh folder using the ssh-Remote plugin.
code /path/
Visual studio code also stores your ssh folders on recent folders so i wish that there's a command to call that path or something like that.

Visual studio: How to open a specific solution directly from command line?

I want to open a specific solution (.sln) in visual studio directly from the command line.
Using the command, I tried
devenv "full-path-to-sln-file.sln"
but it didn't work.
How do I do this?
You can just use explorer.exe !!
In your command line type in:
explorer mysolution.sln
Use the full path to the devenv.exe executable and the full path to the sln solution file, both wrapped in quotes and with a space in between. If your solution file is in a network path, make sure that it does not require authentication before accessing the destination folder.
C:\Users\YourWindowsUser>"D:\Visual Studio\Common7\IDE\devenv.exe" "\\networkDirectory\profiles\Desktop\VisualStudioSolutions\Project999.sln"
I wrote an open source application called OpenVSSolution to do exactly this.
Essentially:
Put this helper exe somewhere in your PATH
The exe scans the current directory for a .sln file
The exe opens devenv passing in the sln file
The explanation is on here:
https://davemateer.com/coding/2018/11/14/Open-visual-studio-from-command-line.html
I find this incredibly useful and is how I open all solutions.
You can open a solution file with Visual Studio directly if you are within a folder that contains the solution file, looking for it recursively (Powershell 7.0) by doing the following:
Open powershell, type
echo $profile
Open up the location of your profile, save the below into it:
function vs
{
Get-ChildItem *.sln -Recurse | Invoke-Item
}
Then just type vs into a folder and it will go through the sub directories looking for the solution file and open one if found
Try WhatsNew. From the readme:
Why fish around for Visual Studio solution files using Windows Explorer when you can find and launch them from your terminal window with just three little letters? Run sln (an alias for Open-Solution) to recursively search your current working directory for a solution file and launch it, if one is found.
for macOs I just use:
open projectname.csproj
it will open it in visual studio 2019 for me

C++ transform T4 template ignore output file

I'm using TextTransform.exe to generate multiple C++ files. Since the tool is not supported directly within Visual Studio for C++ projects I call it by command line (inspired by T4 Generating C++ Code).
In order to generate multiple files I use https://github.com/areve/Entity-Framework-T4-Templates/blob/master/src/dev/MultiOutput.tt that's why I don't need the standard output which is normal generated by the tool.
I call TextTransform.exe like:
"C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\14.0\TextTransform.exe"
-out "<what to put here that NO file is generated?>"
C:\Test.tt
I'm using Microsoft Windows. Maybe there is a "hack" to provide any kind of special char which would be accepted by the program but it wouldn't be possible to actually create a file out of it.
Is there a possibility to provide any command which generates NO file when I execute this command?
Update
As mentioned by #ImprobabilityCast using NUL is a way to go. It's not producing any file but the custom build where I run the tt file with is failing with the message:
Performing Custom Build Tools
CUSTOMBUILD : error : FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path.
I reach what I want but it's not so "nice" that the build action is failing.
Not sure why you don't want the files, but...
In linux we have a wonderful thing called /dev/null that is essentially an empty void just for things like this. I did a quick search, and Windows has it's own equivilent: NUL
Thus, the command you want is:
"C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\14.0\
TextTransform.exe" -out NUL C:\Test.tt
No. The way text transformation was built was only thought to produce a single output file. Multi output was a logical evolution for T4 templates but Microsoft has not evolved it for years now.
The code that you're using (as am I) is basically a hack around that. It uses a very ugly way of using the EnvDTE to manipulate the project system that will probably end up not working one of these days when MS decides to rewrite that system (and one could argue that day is coming).
T4-editor, for example, has a slightly different way of achieving the same thing but you can see that the output still produces the "dummy file":
http://t4-editor.tangible-engineering.com/blog/how-to-generate-multiple-output-files-from-a-single-t4-template.html
I've found a satisfing solution for my problem. Since Microsoft Visual Studio allows for custom build tools to enter multiple lines I realized that I can delete the file generated by the TextTransform.exe I don't need.
So the command I put into "Command Line" contains two lines now:
"C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\14.0\TextTransform.exe" -out "%(DefiningProjectDirectory)$(TempOutputFile)" C:\Test.tt
DEL /F "%(DefiningProjectDirectory)$(TempOutputFile)"
The first line is the actual TextTransform call which produces me all the files I want including the output file I don't need but can't stop to be created.
The second line just deletes me the file I don't need.
This command expects a project variable calles "TempOutputFile". In this way I skip any typo's. For example:
<PropertyGroup Label="Globals">
<TempOutputFile>DoNotCheckin.h</TempOutputFile>
</PropertyGroup>

debugging with visual studio using redirected standard input

I am debugging c++ console application with Visual studio. I exhausted of inserting the same input every time I debug this program. I would like to use the same input more times.
I do this without debugging in command line with command: Program.exe < 1.in
Is it possible to use debugging with standard input redirected from file???
I already tried looking in to procejt properties. I tried setting Command to $(TargetPath) < 1.in instead of $(TargetPath).
I also tried setting Command Arguments to < 1.in. Niether of these method worked.
I am using Visual Studio 2012. But this is probably same in all versions of studio.
This is a supported debugging scenario. You do have to make sure that the debugger can find the file. Leave the Command setting at $(TargetPath). A possible value for the Command Arguments setting is:
< "$(ProjectDir)test.txt"
if the input file "test.txt" is located in the project directory. Or type the full path of the file to be sure. The MSDN article that describes this feature is available here.
I just create a file called stdin.txt in the project
1) set the Build Action to Content
2) Copy to Ouput Directory: Copy if newer
Then when you build stdin.txt is copied to the same folder as the executable.
Then in project properties debug|command line arguements enter the following
< stdin.txt
There is no need to use a path macro
If you don't want to mess with the the path you can add a new file with a right click on the source files folder in the solution explorer and then paste to it the content from the wanted file. And then change the command argument to the new file name.

bat script only runs first line?

When I copy/paste the lines below into a cmd window it executes without a problem.
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
msbuild proj\projsln /p:Configuration=Debug
proj\proj\bin\Debug\proj.exe my args
However when I save it as DoStuff.bat I get the message below (which is the text from executing vcvars32.bat), then nothing else. It does not build my project and obviously doesn't run the newly built executable.
Why doesn't it and how do I have it run all three commands?
>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
Use CALL to call another batch file.
Well, there has to be a reason it isn't continuing. Is it that the command is waiting for some input? Thats all that I can think of. Try re-directing the output of the batch file to a log and see what is going on.
Alternatively, split the batch file into separate batch files and put a CALL before each call to the batch file.

Resources