After looking at silverbyte's question, I decided to run some tests on skipping filePaths and I think I've found a bug. It seems that when skipping objectName=filePath AND skipAction=Delete, the file is deleted anyway. Performing the same statement with dirPath (and filtering on the containing folder), it works just fine.
I've also discovered that using skipAction=Delete but omitting AbsolutePath produces weird results (like only skipping files in the root directory), but I decided to leave that out since its behavior is undefined.
Below is a batch script which reproduces the problem (don't worry, it's safe. Just run it in an empty directory):
@ECHO OFF
REM ******** this stuff is only to read the path to the latest WebDeploy on your machine ***********
for /F "usebackq tokens=1,2,*" %%h in (`reg query "HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy" /s ^| findstr -i "InstallPath"`) do (
if /I "%%h" == "InstallPath" (
if /I "%%i" == "REG_SZ" (
if not "%%j" == "" (
if "%%~dpj" == "%%j" (
set MSDEPLOY="%%j\msdeploy"
)))))
ECHO Creating structure...
ECHO \FileInRoot.txt
ECHO \SubDir\FileInSub.txt
ECHO.mkdir source
mkdir dest
echo 1 > dest\FileInRoot.txt
mkdir dest\SubDir
echo 1 > dest\SubDir\FileInSub.txtecho %CD%
ECHO. & ECHO Executing tests using filePath
PAUSEECHO. & ECHO -skip:objectName=filePath,skipAction=Delete,absolutePath=.*FileInSub.*
ECHO EXPECT: FileInSub.txt to be skipped
ECHO ACTUAL:
%MSDEPLOY% -whatif ^
-verb:sync ^
-source:dirpath="%CD%\source" ^
-dest:dirpath="%CD%\dest" ^
-skip:objectName=filePath,absolutePath=.*FileInSub.*,skipAction=Delete
PAUSEECHO. & ECHO -skip:objectName=filePath,skipAction=^<omitted^>,absolutePath=.*FileInSub.*
ECHO EXPECT: FileInSub.txt to be skipped
ECHO ACTUAL:
%MSDEPLOY% ^
-whatif ^
-verb:sync ^
-source:dirpath="%CD%\source" ^
-dest:dirpath="%CD%\dest" ^
-skip:objectName=filePath,absolutePath=.*FileInSub.*
PAUSE
ECHO. & ECHO -skip:objectName=dirPath,skipAction=Delete,absolutePath=.*SubDir.*
ECHO EXPECT: FileInSub.txt to be skipped
ECHO ACTUAL:
%MSDEPLOY% ^
-whatif ^
-verb:sync ^
-source:dirpath="%CD%\source" ^
-dest:dirpath="%CD%\dest" ^
-skip:objectName=dirPath,absolutePath=.*SubDir.*,skipAction=Delete
PAUSEECHO. & ECHO -skip:objectName=dirPath,skipAction=^<omitted^>,absolutePath=.*SubDir.*
ECHO EXPECT: FileInSub.txt to be skipped
ECHO ACTUAL:
%MSDEPLOY% ^
-whatif ^
-verb:sync ^
-source:dirpath="%CD%\source" ^
-dest:dirpath="%CD%\dest" -skip:objectName=dirPath,absolutePath=.*SubDir.*
PAUSE