Deleting entire folder in Visual Studio Post-build event - visual-studio-2010

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.

Related

While deleting folder in Window OS it shows error : THE FOLDER IS DOESN’T EXIST

For Example :
suppose I have a directory like "C:\Users\user\Downloads\Compressed\Developing Android Apps Videos"
Now while deleting "Developing Android Apps Videos" folder, If an error popped up with this message that "FOLDER DOESN'T EXIST", How to fix such issue ???
you have to follow this steps to solve this issue:
open cmd administration
enter command -> cd /d C:\Users\MK\Downloads\Compressed\Developing Android Apps Videos
enter command -> dir /x
After the 3rd step, you can see some folder name and you need to use that name for 5th step.
enter command -> rmdir /q /s enter-folder-name
Hopefully, this could help you and please find an attachment for the exact process.
Thank you
You can try below command also.
1.Open command prompt
2.Run below command
RD /S /Q pathOfTheFolder
ex: RD /S /Q C:\Users\Me\Documents\NewFolder
Here
/S- Delete all sub folders and files. So once you delete any folder, all files and folders with in that folder will be deleted
/Q - Doesn't show Yes/No confirmation dialog box before deleting files are folders.

xcopy exited with code 4, how to get this resolved?

I am running a build from Team Foundation Server(TFS), and the build is failing with the error
"xcopy "C:\eComObjects_MP10\Microsoft\DynamicsCrm"
"D:\Builds\19\Unicorn\MaintPackage10- Daily\Sources\MaintPackage10\WebInterface\Store\Inetpub\wwwroot\Bin\DynamicsCrm"
/E /Y /I " exited with code 4".
When I simply go to the command prompt and run the above command, it fails, but when this command is run after removing /E/Y/I and the double quotes at the end, it works fine from the command prompt. What might be wrong here ?
Since it's also failed with command prompt, so it's not related to TFS build.
Xcopy exit code 4 means "Initialization error occurred. There is not
enough memory or disk space, or you entered an invalid drive name or
invalid syntax on the command line."
There are various reasons for this. In your case it may due to the length of Source and Destination (Path length). resulting path names exceeded the maximum allowed length. It may due to the /e option /e : Copies all subdirectories, even if they are empty. Use /e with the /s and /t command-line options. Xcopy command reference.
For more ways, you could refer below similar question:
What is going wrong when Visual Studio tells me "xcopy exited with code 4"
Command copy exited with code 4 when building - Visual Studio restart solves it
In addition to the possibility of disk space or command line syntax errors, this can also occur due to permissions (and maybe other causes?)
What I would recommend is to open a command prompt and copy/paste the offending XCOPY command so you can see the actual error that's occurring. In my case it was "Access Denied" which prompted me to check the destination folder where I found that my user account didn't have appropriate access.

TortoiseSVN client-side hooks in project properties (delete cache files)

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.

XCopy will not copy in visual studio

I'll copy a exe into another folder with a post build event from visual studio. This should happens every build. I haven't any errors, the exe output is in a custom folder, but it will not copy into another folder, why? The build output from visual studio is only: Build successfully. 0 files copied.
With this script, I've changed the output folder: $(SolutionDir)..\..\build\$(ProjectName)\. And with this, I'll try to copy the result into another folder: xcopy "$(SolutionDir)..\..\build\$(ProjectName)\$(TargetFileName)" "$(SolutionDir)..\..\bin\AutoCopy-Server.exe*". With the "*" at the end, I say, that it is not matter, if this is a file or a directory. What's wrong here? The file in my output folder, is successfully "copied". It seems, that xcopy can't find the file, but there isn't any error. Has someone an idea?
It sounds like this xcopy bug. If so, a workaround is to append <NUL: to the end of the xcopy command, eg:
xcopy "$(TargetDir)\*.exe" "$(SolutionDir)\bin\" /S /Y <NUL:

Batch program to delete a folder

I'm trying to automate a little backup process of a folder from the computer to a network-drive. I found the code below to delete the folder on the network drive but I can't get it working because it says "Unable to find the specified file" for each files that it tries to remove. Why?
rd /s /q "\\MY SERVER\mysharename\myfolder"
Maybe there is a problem with concepts. It is not "\\server\folder", but "\\server\shareName". And you can not remove the share with a rd command.

Resources