XCopy will not copy in visual studio - 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:

Related

XCopy is not working (File not found *.*)

I'm tyring to copy a folder from my Visual Studio 2015 Project's root directory into the output directory (as it breaks the application without it), so I decided to add xcopy to the post-build commands.
xcopy "$(SolutionDir)Content\*.*" "$(TargetDir)Content\" /s /i /y
I'm getting the following when it runs, and right now I can't even test this application because of xcopy.
1> File not found - *.*
1> 0 File(s) copied
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): error MSB3073: The command "xcopy "E:\Data\Projects\Vessel\Games\TheThing\Content\*.*" "E:\Data\Projects\Vessel\Games\TheThing\TheThing\bin\DesktopGL\AnyCPU\Debug\Content\" /s /i /y" exited with code 4.
I'm also getting problems with Xcopy and postbuild events in visual studio from time to time.
My fix is generally to create a batch script which contains the xcopy.
The batch script then is called by:
call "$(SolutionDir)scripts\copyfiles.bat"
as a post script event.

How to write xcopy command to copy only certain DLLs from project folder to bin folder

I'm currently working in VS 2015. I have a specific unmanaged DLL that needs to be copied to my bin folder after my build operation manually.
How can I write an xcopy command to copy only that specific DLL on successful build in VS? I have figured out where it needs to be written, but not sure how!
How to write xcopy command to copy only certain DLLs from project folder to bin folder
You can add a xcopy command in post-build-event (Properties->Build Events->Post-build-event command line) to copy those specific dll to the bin folder:
xcopy.exe "$(ThePathOfSpecificDll)\Specific.dll" "$(OutDir)"
Note:
You can use Macros to specify the path.
Do not ignore double quotation marks.

Copy failed in batch script

I have the following lines in my VS's bat file:
copy "%1web.%2.config" "%1web.config" /y
copy "C:\inetpub\Config\%2\api\smtpSettings.config" "%1smtpSettings.config" /y
Idea is to copy environment-related configuration into project's main configuration files. %1 is a path to project, %2 is a environment name.
The file is executed via VS's pre-build step: "$(ProjectDir)Deploy.bat" $(ProjectDir) $(ConfigurationName)
Problem is that first line works fine, while second all the time fails with:
The system cannot find the file specified.
I checked the path, it is valid, at least pasting it into windows explorer I can navigate to file. Any ideas?
It would appear that "C:\inetpub\Config\Development\api\smtpSettings.config" or "C:\inetpub\Config\Production\api\smtpSettings.config" does not exist.
If they do exist, then you may be facing a security error.

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.

Deleting entire folder in Visual Studio Post-build event

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.

Resources