I'm trying to write a powershell script that launches Visual Studio with a solution and run a macro.
devenv.exe "$PATH\TestSolution.sln" /Command Macros.MyMacros.TestMacro
However, it takes time to load the solution so that the macro doesn't run.
Is there a way to wait(sleep) for 15 second and run the macro?
Suspends the activity in a script or session for the specified period of time. use Start-sleep http://technet.microsoft.com/en-us/library/hh849939.aspx
Related
I would like to close webdriver from task manager, when I stop test execution in visual studio. Normally I could use AfterTestRun to close the driver, but, when I click over stop button in visual studio meanwhile test execution is running AfterTestRun isn't execute, so web driver is still open.
You can't do this, as Visual Studio/Test Explorer is killing the test execution process when you stop the execution. No code is executed then and there is also no place where you could put some code that gets executed.
I have a command line script that kills all the processes when I press a shortcut.
You can kill a process via command line on Windows this way:
taskkill /f /im chromedriver.exe
This kills all processes with the name chromedriver.exe.
I have multiple solutions generated by script from cMake and I want to open all at once in a Visual Studio instance.
I found /command as parameter of devenv.exe when running from command line.
There are commands like File.OpenProject and File.AddExistingProject, but I can only pass one of them to /command at the start.
As I see so far there is no character to separarate the commands in one string.
Thanks in advance
I have a command in my post-build event command line in Visual Studio 2010
Powershell -command .'$(SolutionDir)Powershell\MoveFiles.ps1'
And when the event runs, I get an error that the command "exited with code 1."
However when I run the same command on the command line (see below), with an actual directory instead of the VS2010 macro, it works perfectly.
Powershell -command .'C:\TFS\MyProject\Main\Source\Powershell\MoveFiles.ps1'
So it seems that the problem lies with how VS2010 is executing the command.
What could be causing this problem?
[UPDATE]
I have also tried changing the post-build event to:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Powershell -command .'C:\TFS\MyProject\Main\Source\Powershell\MoveFiles.ps1' and I get the same result as described above. It works when run from the command line but not from VS 2010.
Two things:
Use the -file parameter instead of the -command parameter.
Use double quotes.
powershell.exe -file "$(SolutionDir)Powershell\MoveFiles.ps1"
If you are running on a 64-bit OS, you will need to specify the full path to the 64-bit version of powershell since Visual Studio is a 32-bit app.
There is an answer in this question that has a workaround for the problem.
Is there a way to use the popular Console2 cmd.exe replacement for Visual Studio debugging? In other words, when I debug a console app under VS, I want it to use Console2 instead of cmd.exe.
Interesting question. I looked into it, there are some options but none are pretty.
Console.exe takes arguments, so it's possible to start it with a specific tab and execute an arbitrary process. However, this process will always be run within it's own cmd.exe; for example if your program is c:\my.exe and you launch Console as console.exe -t tabname -r c:\myexe Console2 internally calls CreateProcess( ... cmd.exe c:\my.exe ... ), as a result you can't even see the output of my.exe. This is easily solved though: launch it as console.exe -t tabname -r "/k c:\myexe": the /k switch makes the cmd.exe stay active and you can see your program's standard output. (I looked through the source but couldn't find a way to 'attach' a tab to a currently running Console instance, so launching with arguments will always create a new instance, not sure this is what you are looking for?
You can easily modify the project's debugging properties to reflect the above:
Command: /path/to/console.exe
Command Arguments: -t tabname -r "/k $(TargetPath)"
When starting your exe from within VS, it will launch your exe witin a Console session. However the debugging won't work as VS will try to debug console.exe, not my.exe since that is now a different process. Putting a DebugBreak(); as first line in your exe's main() will sort of solve this, as it will present you the option to debug your exe. All in all, this may a bit too much of a hassle to achieve what you want, but i don't think there's another way: Console always spawns a new process, so the only way to get it debugged is to attach the debugger to it after that process started.
Scott Hanselman blogged about this.
He suggests using this value for Console Settings > tabs > Main > Shell :
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
Sadly for me, This does not appear to work for Visual Studio Express 2010, which lacks a vcvarsall.bat file.
I typically run a script each night that updates my code from SVN, then builds it. The last few days I have a long debug run I'd like to start at night so it can go through the hour or two it takes to hit the error before I come in the next morning. The way I've done this so far is to VPN in later in the evening to start the run.
Is there any way I can have a script tell an active Visual Studio instance to execute a macro? Either that or launch a new instance that would run a macro once it's open. This way I could automate the whole thing.
To execute a macro or a command in a new session, do:
devenv /Command CommandName
To debug an executable, do:
devenv /DebugExe ExecutableFile
To run a solution using default settings:
devenv /r Solution
More info: http://msdn.microsoft.com/en-us/library/a329t4ed(VS.80).aspx