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
Related
By typing cmd or powershell to the Windows File Explorer path bar (the photo above), you can open cmd or powershell in the current path your File Explorer is in.
But how about vscode? Can I add this vscode to the path bar keywords so I can type vscode, press enter and quickly open Visual Studio Code in the directory the File Explorer is in? If so, how? Some registry magic?
Just found out that by typing code.cmd ., you can do the thing that I wanna do exactly.
code.cmd . is too long? Got you covered!
Go to C:\Program Files (x86)\Microsoft VS Code\bin (This is default path, yours might be different)
Copy the code.cmd to code.bat
And you can now type code to the path bar of the File Explorer and do the samething easier :D
P.S.: You can also change code.bat to something else like vscode.bat and you can type vscode to the path bar to do the samething :DDD
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.
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).
If I create an .exe file with Visual Studio 2010 (in the bin/Debug folder) is it possible to use a bat file to start this program?
I tried the below in my bat file:
start "c:\Services\ServicesChecker\ServicesChecker\bin\Debug" ServicesChecker.exe
however when I run it, it says Windows cannot find ServicesChecker.exe even though if I browse to the location I can see it?
In your command, the "c:\Services\..." is the title given to the window, and is not used to find the executable.
Try:
start c:\Services\ServicesChecker\ServicesChecker\bin\Debug\ServicesChecker.exe
Its because there is no option in start by which you can specify the path.
Use
start "c:\Services\ServicesChecker\ServicesChecker\bin\Debug\ServicesChecker.exe"
this should work.
Try just using the file path rather than start, and you need to include the filename in the same quoted path, like this:
"c:\Services\ServicesChecker\ServicesChecker\bin\Debug\ServicesChecker.exe"
How to launch .Exe file or .VBS script when visual studio solution(.sln) is opened ?
Associate a .SLN file with your own executable instead of devenv. In your executable, if the solution being opened matches then delete the necessary files. Then execute the devenv and pass the solution full path and name as a parameter.