I'm trying to launch a grunt process that will watch for .js file changes and transpile them into one file using grunt tasks. I can run it manually all day long, but I want to make it a pre-build so when a new dev gets the solution, building will launch the watcher. The problem (as you may have guessed) is that the grunt process stays running, so as a pre-build event, it never continues the build. I thought that using start would be asynchronous and would launch it without VS waiting on it to complete to continue the build, but I was mistaken. So, currently, my pre-build event is
cmd /c start $(SolutionDir)ProjectName.Web\run-grunt.cmd $(SolutionDir)
and run-grunt.cmd looks like
cd %1ProjectName.Web
grunt
This works but hangs until I close the cmd window which defeats the whole purpose. So, two questions:
Is this the wrong way to get this watcher kicked off?
Is there a way to structure these such that VS will launch the cmd and then resume the build without waiting for a return?
Have you tried setting your pre-build event to simply run a batch file that executes your current pre-build event? It seems like it will work because the batch file that Visual Studio executes will actually complete, leaving another command window in its wake.
I tested my theory with two batch files:
test1.bat
call "cmd /C start test2.bat"
echo test1
test2.bat
echo test2
pause
If you're still needing some parts of the grunt task to execute pre-build, you can break them out into separate tasks, so your pre-build event may end up looking like this:
cd $(SolutionDir)ProjectName.Web\
grunt build
grunt-watch.bat
Related
I have a simple one line bat file that runs a curl localhost:port. My curl.exe is in the same folder as the bat I don't have it installed globally. It runs fine if I double click it, it also runs fine if I right click in task scheduler and select run task. It also says it completes the "scheduled tasks" successfully but nothing happens (I'm sure of this as I'm checking data that should update if the script is run, and it doesn't happen under the scheduled/automatic scenarios). After reading lots of users issues I tried configuring in two ways (all on 5 minute updates):
Common Way
Action: Start a Program
Program/script: C:\p\updater.bat
Start in: C:\p\
Other Way
Action: Start a Program
Program/script: cmd
Add arguments: /c start "" "C:\p\updater.bat"
I have set permissions to the bat and the containing folder to allow all for all users/etc. Neither work when automatically triggered, neither error. I've tried in Server 2008 and Windows 10 (my OS) mode. Both work if I right click run task, neither automatically, any ideas?
Default working directory for scheduled script is %Windows%\system32. Try to add in first line to you updater.bat:
cd c:\p\
For diagnostic, you can add output redirect to you commands in bat file:
echo Script Started >> c:\p\log.txt
curl SomeCommand SomeCommand >>c:\p:\curloutput.txt
echo Script Ended >> c:\p\log.txt
and check files log.txt and curloutput.txt after execution of your script
I made some batch files for builds etc, and some stay open until I press a key, some don't. Since the batch files are started on doubleclick from explorer, the last command always is pause.
This works:
#echo off
sencha app build testing
pause
This does not work:
#echo off
cscript /nologo newKey.vbs
sencha app build production
copy build\production\MyApp\app.js phonegap\www\
cd phonegap
cordova build android wp8
pause
Why does pause not wait for my keystroke here? Does it get any "keystroke" from the command before?
I am using Windows 8.1, if that matters...
Because cordova is cordova.cmd, a batch file, and when a batch file invokes another batch file the execution flow is transferd to the called batch but does not return to the caller
You will need to use the call command, so the execution flow returns to the caller
call cordova build android wp8
I know there are similar questions already out there, but none of the other solutions seem to help.
Using Windows 7, I have an executable (for this explanation, I am calling it test.exe) that takes a parameter of the current date.
Example when using the run command:
c:\test.exe 12/26/2014
The executable needs to be ran on a daily schedule.
I have the following batch file set up to run the exe with the required parameters:
#echo off
::This batch will be ran daily to start the exe program
set dateFormat=%DATE:~4,2%/%DATE:~7,2%/%DATE:~10,4%
echo Batch started %dateFormat% %Time%>> BatchLogfile.txt
set testfile=C:\test.exe
start %testfile% %dateFormat%
pause
I can run the batch successfully by double-clicking on it in explorer, but when I add it as a scheduled task it does not actually start the exe.
The batch does run and I can see the processes for the cmd and the exe, but the exe "interface" does not pop up. The echo line in the batch writes out to the log file successfully.
On the scheduled task, I am currently using cmd for the program/script and the following params:
/k "C:\test.bat"
I have also tried the following arguments unsuccessfully in the task scheduler:
C:\Windows\System32\cmd.exe
/c start "" "C:\test.bat"
/k start "C:\test.bat"
Is there anything else I should try so that the exe "interface" shows on the screen? Perhaps there is a better way to run the exe other than task scheduler?
If you want to see the GUI for test.exe, then you will need to configure the respective Windows Scheduled Task to "Run only when user is logged on". Of course then the process would only run for the configured user account.
This is available to select in the Security Options section in the General tab of the respective scheduled task.
I want to setup a windows cron job to update svn. I created a batch file with this step:
START TortoiseProc.exe /command:update /path:"C:\svn" /closeonend:0
and setup the task scheduler to run this daily. This svn requires a password which I want to enter each time rather than cache it. The batch file works as expected without any issues.
The task scheduler shows that the job was successfully executed. However, I don't get the GUI to enter the password, neither does the directory get updated. Also, when I tried to manually update the svn directory thereafter, it says that svn is locked.
Why is task scheduler reporting successful?
Why is svn getting locked?
Task scheduler reports success because START seems to return exit code 0. START only starts an application and exits. It doesn't wait until the started application has exited. The task scheduler never sees the exit code of TortoiseProc this way.
You can do this with START WAIT. Enter START /? in a CMD for more information.
You can also do this with CMD /K itself. Enter CMD /? in a CMD for more information.
But I don't think you need START or CMD at all. You can either run TortoiseProc directly or call it via a batch script. In the batch script you can add more debugging like echos and redirected output in files to see what happens.
Do not use TortoiseProc.exe for this task! Use Subversion command-line client (svn.exe). Read the docs:
Remember that TortoiseSVN is a GUI client, and this automation guide
shows you how to make the TortoiseSVN dialogs appear to collect user
input. If you want to write a script which requires no input, you
should use the official Subversion command line client instead.
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