Suppose I have a destination folder structure that looks like this:
D:\DEPLOY\DEST
│ 0.txt
│
├───a
│ a.txt
│
└───b
├───b1
│ │ b1.txt
│ │
│ ├───b1a
│ │ b1a.txt
│ │
│ └───b1b
│ b1b.txt
│
└───b2
b2.txt
I also have a source folder structure that looks like this:
D:\DEPLOY\SOURCE
└───b
└───b1
└───b1a
b1a-new.txt
I would like to synchronize the source to the destination, but only below the \b\\b1\b1a
path. To do that, when running MSDeploy, I add a skip rule matching all dirPaths not containing this path:
msdeploy -verb:sync
-source:contentPath=D:\deploy\source
-dest:contentPath=D:\deploy\dest
-skip:skipAction=delete,objectName=dirPath,absolutePath='(?!\\b\\b1\\b1a)'
-whatif
resulting in:
Info: Deleting file (D:\deploy\dest\0.txt).
Info: Deleting file (D:\deploy\dest\b\b1\b1.txt).
Info: Adding file (D:\deploy\dest\b\b1\b1a\b1a-new.txt).
Info: Deleting file (D:\deploy\dest\b\b1\b1a\b1a.txt).
Total changes: 4 (1 added, 3 deleted, 0 updated, 0 parameters changed, 0 bytes copied)
To my surprise, this does more than expected. MSDeploy also deletes the files 0.txt
and b1.txt
, which are under a dirPath that I expect to be skipped based on the regex. I tried various permutations of the absolutePath regex, but to no avail.
What should I be doing instead? Or is this beyond the possibilities of msdeploy?
Note: this example is simplified. In reality my source is package, not a contentPath. That is why the obvious answer of syncing at the b\b1\b1a
-level would not apply.
You've specified that you don't want it to delete directories outside that folder, but your skip rule says nothing about files. Just remove ,objectName=dirPath
from your skip directive and it will skip deletes on any provider.
As an aside, skip rules are actually quite nuanced in their behavior. I have a blog post that digs into it which might help: Demystifying MSDeploy skip rules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With