Reputation: 16411
I have many web applications in a Visual Studio solution.
All have the same post build command:
xcopy "$(TargetDir)*.dll" "D:\Project\bin" /i /d /y
It would be useful to avoid replacing newer files with old ones (e.g. someone could accidentally add a reference to an old version of a DLL).
How can I use xcopy to replace old files only with newer DLL files generated by Visual Studio?
Upvotes: 30
Views: 44071
Reputation: 220
User following command to copy all new and modified file from source to destination
xcopy c:\source d:\destination /D /I /E /Y
/D to check any modified file are there
/I If the destination does not exist and copying more than one file, assumes that destination must be a directory.
/E To copy directory and sub directories
/Y to suppress any over write prompt.
Upvotes: 6
Reputation: 19
Not tested, but I use a similar command script for these sorts of tasks.
set DIR_DEST=D:\Project\bin
pushd "$(TargetDir)"
::
:: Move Files matching pattern and delete them
::
for %%g in (*.dll) do (xcopy "%%g" "%DIR_DEST%" /D /Y & del "%%g")
::
:: Move Files matching pattern
::
:: for %%g in (*.dll) do (xcopy "%%g" "%DIR_DEST%" /D /Y )
popd
Upvotes: 1
Reputation: 21089
From typing "help xcopy" at the command line:
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
So you already are using xcopy to only replace old files with new ones. If that's not happening, you may have to swap the positions of the /i
and /d
switches.
Upvotes: 33