Im using a command line prebuild task in the ccnet.config file to delete the contents of thw working directory before i do a clean build.
<prebuild>
<exec>
<executable>%SYSTEM32%\cmd.exe</executable>
<buildArgs>/c "if exist "C:\CruiseControl\Working" rd /s /q "C:\CruiseControl\Working""</buildArgs>
</exec>
</prebuild>
The problem is I get an error:
System.IO.IOException: Unable to execute file [C:\CruiseControl\Working\cmd.exe].
it seems to be looking for cmd.exe in the working folder.
So I tried adding the path to cmd.exe instead as follows:
<prebuild>
<exec>
<executable>%SYSTEM32%\cmd.exe</executable>
<buildArgs>/c "if exist "C:\CruiseControl\Working" rd /s /q "C:\CruiseControl\Working""</buildArgs>
</exec>
</prebuild>
Any help would be great?
I have found the answer to my original question:
I simply had to put the cleanCopy true inside the sourcecontrol block.
<sourcecontrol type="svn">
<trunkUrl>TRUNK-URL</trunkUrl>
<executable>SVN.EXE</executable>
<username>TEST</username>
<password>TEST</password>
<cleanCopy>true</cleanCopy>
</sourcecontrol>
The path where is located cmd.exe is in your %PATH% Environment variable. You don't need to explicitely set it (you can verify it by typing cmd in the execute prompt) :
<prebuild>
<exec>
<executable>cmd.exe</executable>
<buildArgs>/c "if exist "C:\CruiseControl\Working" rd /s /q "C:\CruiseControl\Working""</buildArgs>
</exec>
</prebuild>
As for the directory use problem. I think you wish to delete a subdirectory of C:\CruiseControl\Working instead of the whole Working. It could also be that svn or another process is working on it. What happens if you run
if exist "C:\CruiseControl\Working" rd /s /q "C:\CruiseControl\Working"
directly in cmd?
I have the same problem with cmd.exe in a block. I have cleanCopy set to true in a multi source control block with Source Gear Vault. Nothing here or anywhere else has solved this problem other than putting my single line command into a .cmd file, but I would rather not have to create a .cmd for every little line I need to run from the command prompt.
Related
I have several php-projects under SVN control. I want to delete compiled php-template files after update on the client side; these files are located in ./tmp/smarty/compile folder. So using windows command line I can do this using
del /Q path_to_my_project\tmp\smarty\compile
If I run this command in cmd.exe all files are successfully deleted.
using projects properties tsvn:postupdatehook I should use %REPOROOT% placeholder for project path. so my command becomes:
del /Q %REPOROOT%\tmp\smarty\compile
del is the cmd.exe command, so I need to run cmd.exe first and then run desired command. so finally my hook command looks like:
cmd.exe /c del /Q %REPOROOT%\tmp\smarty\compile
when I run this using Win+R (with reporoot changed to full path) it works fine too.
Then I put this line to SVN properties (I should replace \ slashes to /, overwise SNV returns http-path to repository, not local path), and try to update project. TortoiseSVN asks me if I want to run hook:
cmd.exe /c del /Q D:\_projects\webCakePHP\.....\tmp\smarty\compile
So here reporoot is successfully translated to correct working copy path.
Everything looks fine, but when I run this hook, it successfully deletes files in tmp\smarty\compile but it also deletes all files from working copy dir.
the question is, what am I doing wrong, and how to delete files after update right way.
I've tried to put quotes some ways but it doesn't delete enything at all or says that there is no such directory.
thanks
as an alternate solution to my question, i've created .bat file in %REPOROOT%/bin folder, which deletes files:
pushd %~dp0..\tmp\smarty\compile
del /Q *
popd
and my hook cmd string is %REPOROOT%/bin/clearCache.bat.
this is not exact answer to my question because it requires bat-file creation and isn't one-line hook.
I'm trying to delete a folder in my output directory using the following command line:
del /F "$(TargetDir)Content\"
Tho I always end up exiting with error code 1. I've tried several different ways, without /F, with/without slash both before and after, etc.
Error 1 The command "del /F "E:\proj\bin\Windows\Debug\Content\"" exited with code 1.
There are a lot of questions regarding deleting files in post-build event command lines in visual studio, which works fine, but I can't seem to delete a folder without getting code 1.
Any help is appreciated!
RD /S /Q "Full Path of Folder"
In your case:
RD /S /Q "$(TargetDir)Content\"
Browse to the same folder using Command Prompt, and then run that command and see what the actual error is. Might be permissions or something is in use.
i have run very simple script:
xcopy some.exe c:\folder\ /h/y and it works normally. but when i try to run .bat file with this code as administrator - cmd line opens for a moment but nothing happens (file not copied). Can anyone explain this issue?
i also tried to use echo xcopy instead of xcopy, but nothing had changed.
i need only admin running of .bat file, cause i want to copy file in \windows\system32 folder
when you start a batchfile as administrator, it's working directory is C:\windows\system32\. So your script doesn't find your file. Either work with absolute paths, or change the working directory.
You can change it to the directory, where your batchfile resides with:
cd /d "%~dp0"
Note: to keep the window open to read any errormessages, append a pause command.
I have a .bat file that has the following commands:
c:
cd %1
"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 & for /f "delims==" %%F in ('dir /b *.pdb') do vsinstr /Coverage "%%~nF.dll"
I am executing the bat file from a cruise control project like this:
<exec>
<executable>cmd.exe</executable>
<buildArgs>"c:\Development\Batch Scripts\CodeCoverageSetup.bat" $(CodeCoverageSetupWorkingDirectory)</buildArgs>
</exec>
When the CC.Net project runs, the task is executed but it does nothing, and it runs indefinitely.
However, when I execute the batch script directly from cmd it executes perfectly.
Any ideas on how to get this to work?
PS: Any suggestions on how I can make CC.Net run the cmd window so that I can see what commands are being executed? Because the CC.Net shell does not give any useful debug info.
You are missing the /c for the cmd.exe to execute another process and exit at end.
Fixed exec block:
<exec>
<executable>cmd.exe</executable>
<buildArgs>/c "c:\Development\Batch Scripts\CodeCoverageSetup.bat" $(CodeCoverageSetupWorkingDirectory)</buildArgs>
</exec>
OR you can simply remove cmd.exe reference.
<exec>
<executable>c:\Development\Batch Scripts\CodeCoverageSetup.bat</executable>
<buildArgs>$(CodeCoverageSetupWorkingDirectory)</buildArgs>
</exec>
I can answer one part.
//PS: Any suggestions on how I can make CC.Net run the cmd window so that I can see what commands are being executed? Because the CC.Net shell does not give any useful debug info. //
Shut down the CC.NET (Service) (as in Control Panel-Services).
Run ccnet.exe from the command line. (It's values are pulled from ccnet.exe.config).
This will show everything that is happening in a command-window.
......
You can try the .bat file, but I usually end up recoding whatever happens in (what would be your "CodeCoverageSetup.bat") with a Task.
But I understand if you have a alot in CodeCoverageSetup.bat.
Try the command-prompt method and maybe it'll give you a hint about what is happening.
I'm terribly new to scripting on windows. Using windows 7 64.
I'm trying to make a .bat file that I can double click, and have it open a command prompt and automatically cd me to a certain directory.
I tried making a .bat file with
#ECHO OFF
cmd "cd C:\my\destination"
Which opens what looks like a command prompt, but doesn't seem to let me type any commands.
I then tried:
#ECHO OFF
start cmd "cd C:\my\destination"
But this just sent me into a loop opening tons and tons of prompts until my computer crashed :) The .bat file was located in the destination directory if that matters.
This works for me:
#ECHO OFF
cmd.exe /K "cd C:\my\destination && C:"
The quoted string is actually two commands (separated by a double ampersand): The first command is to change to the specified directory, the second command is to change to the specified drive letter.
Put this in a batch (.BAT) file and when you execute it you should see a Command Prompt window at the specified directory.
Use the /K switch:
#ECHO OFF
start cmd.exe /K "cd C:\my\destination"
But IMHO, the most useful switch is /?.
Starts a new instance of the Windows XP command interpreter
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
[[/S] [/C | /K] string]
/C Carries out the command specified by string and then terminates
/K Carries out the command specified by string but remains
/S Modifies the treatment of string after /C or /K (see below)
/Q Turns echo off
...
And only if it does not work, then Google it, as #Neeraj suggested :D
This could be done like that:
#ECHO OFF
cd /D "C:\my\destination"
cmd.exe
If you need to execute a file or command after you open the cmd you can just replace the last line with:
cmd.exe /k myCommand
#ECHO OFF
%comspec% /K "cd /D d:\somefolder"
The /D will change folder and drive and works on 2000+ (Not sure about NT4)
If you take a look at Vista's open command here, it uses cmd.exe /s /k pushd \"%V\" but I don't think %V is documented. Using pushd is a good idea if your path is UNC (\\server\share\folder) To get UNC current directory working, you might have to set the DisableUNCCheck registry entry...
Why so complicated? Just create an alias to cmd.exe, right click on the alias and navigate to its settings. Change the "execute in" to the path you want to have as standard path. It will always start in this path.
just open a text editor and type
start cmd.exe
cd C:\desired path
Then save it as a .bat file. Works for me.
You can create a batch file "go-to-folder.bat" with the following statements:
rem changes the current directory
cd "C:\my\destination"
rem changes the drive if necessary
c:
rem runs CMD
cmd