We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

[BUG] MSDeploy's skip is buggy when used with filePath AND skipActionRSS

2 replies

Last post Dec 12, 2012 11:45 PM by richard.szalay

  • [BUG] MSDeploy's skip is buggy when used with filePath AND skipAction

    Oct 07, 2012 06:17 PM|richard.szalay|LINK

    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.txt

    echo %CD%

    ECHO. & ECHO Executing tests using filePath
    PAUSE

    ECHO. & 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
    PAUSE

    ECHO. & 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
    PAUSE

    ECHO. & 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

  • Re: [BUG] MSDeploy's skip is buggy when used with filePath AND skipAction

    Dec 12, 2012 11:44 AM|TuesdaysGreen|LINK

    Hi Richard.  Unfortunately you cannot skip a single file if the directory itself gets deleted.  The only way to get around this is by adding a skip to the entire directoy like you discovered.  Given this, the "weird" behavior you're seeing where you specify "delete" but no absolute path is actually correct because we're skipping all of the files at the root folder, but the subdirectory is getting deleted by an entirely different provider. 

  • Re: [BUG] MSDeploy's skip is buggy when used with filePath AND skipAction

    Dec 12, 2012 11:45 PM|richard.szalay|LINK

    Thankyou for clarifying. I think I'll write up a blog post on the subject as the behavior is somehow both understandable and confusing :)


    Edit: Here's a link to the article (with apologies for the spam): http://blog.richardszalay.com/2012/12/18/demystifying-msdeploy-skip-rules/