I am pulling my hair trying to understand what's wrong.
I could spend time trying to understand what the hell is going on in msdeploy.exe using Reflector but that's just stupid. This was supposed to be something easy to do with msdeploy, why is it so complicated?
Can someone please say why is the regular expression not matching?
Thanks!
EDIT: See solution below!
Please click on 'Mark as answer' near my comment if you feel I answered your question.
Your regex is fine, I'd guess there's something else at work. Can you try deploying without the skipAction property? It should skip them entirely. If not, something else is wrong.
I will try without the skipAction. But it does not make any sense. I need to give specific actions to skip. I do not want to skip all operations.
I tried many regular expressions, trying to understand the way matching works but without luck.
Matching MUST be RELIABLE! It's the skip rule based on which files are deleted! I am doing backup before deploying but I cannot afford to check each time I am doing the deploy on several sites!
If I am using 'MySite\\MobileForms', it looks like it works, it skips all files from MobileForms.
But I still have no idea why this works and not '.*\\MobileForms\\.*' or 'MySite\\MobileForms\\'
I spent some time digging in the Reflector.
msdeploy does use RegEx::IsMatch for matching the skip rule against the absolutePath.
However, I can't tell what is the actual value of absolutePath.
Is it the actual path ('MySite\\MobileForms\\Data\\ffcff4f4-fc81-4e85-a100-a96d2ea85eca.xml) ?
It clearly it is not, otherwise, my regular expression will match
Why there is absolutely NO words in the msdeploy documentation for how this thing works? Why does it have to be so HARD?
Please click on 'Mark as answer' near my comment if you feel I answered your question.
It appears to me that there is simply a bug in how skips are handled on filePath entries when a skipAction is specified.
According to the docs (msdeploy -help skip):
Including [skipAction] causes the skip to be handled as a skip rule, thus avoiding the actions from being performed on the objects identified by the other settings.
You can avoid the bug by omitting the skipAction property when skipping files, but you'll need to be more specific about what files to skip. Alternatively, you can skip the parent dirPath without a skipAction and it will skip all the files within it (but
it also won't upload any new ones).
It does use regular expression against the destination object's absolute path. The regular expression is exactly like you give it, no mistique in that.
When deploying to my site, the absolute path is exactly how it appears in the output: MySite\\MobileForms\\Data\\MySite\MobileForms\Data\bd13954b-0cb3-41d8-ab8a-eb988ddb8ad1.xml
I found this by creating a custom deployment rule and with debugger attached, I saw how the regular expressions are kept in the defined skip rules.
The way skip rules are applied is based on the order of the synchronization operation(delete, update, add) is done on the actual object(directory or file).
For example, if there's a delete operation on the directory, the skip rules for files within the directory for the delete operation will NOT PREVENT files from being get DELETED!
In my case, the directory MySite\MobileForms get deleted entirely. The skip rule I set for the files is useless.
And for the directory, my mistake is in the regular expression:
I was actually going to point out that quibble in dirPath vs filePath, but after coming across the inconsistant behavior I assumed it was something else.
And don't get me started on these forums. I wish they'd just move to Stack Overflow.
I am facing similar issue. how do we skip deleting a file from secondary server. for example if i want to skip deleting test.html file from any folder.
i have updated the below rule in msdeploy.exe file and msdepsvc file
silverbyte
23 Posts
absolutePath regular expression matching in skip parameter for msdeploy
Oct 01, 2012 06:37 PM|LINK
Hello,
I am having a hard time understanding how does the absolutePath matching works.
I have a .bat calling
It does not prevent deleting the files, here's the output when running the .bat:
Info: Deleting filePath (MySite\MobileForms\Data\bd13954b-0cb3-41d8-ab8a-eb988ddb8ad1.xml).
Info: Deleting filePath (MySite\MobileForms\Data\c2966d9b-0212-46d5-b2cf-a855dfd076fd.xml).
Info: Deleting filePath (MySite\MobileForms\Data\ccb7c771-efce-4066-a329-b98804823d67.xml).
Info: Deleting filePath (MySite\MobileForms\Data\cf84d98a-51a7-4be3-a134-cdba00174b4d.xml).
Info: Deleting filePath (MySite\MobileForms\Data\d3954b7d-8401-4f9e-a2bf-625bec29bac4.xml).
Info: Deleting filePath (MySite\MobileForms\Data\d5039b7e-4e33-479f-a369-39784548babb.xml).
Info: Deleting filePath (MySite\MobileForms\Data\da1860c9-51bd-4f75-89db-75f2f60b8d34.xml).
Info: Deleting filePath (MySite\MobileForms\Data\dca942e1-9a4d-44ce-85fe-10f7f86d1a3c.xml).
Info: Deleting filePath (MySite\MobileForms\Data\e403ecc7-311a-421d-9fa3-e5fe1aef1e74.xml).
Info: Deleting filePath (MySite\MobileForms\Data\e8c4141a-430c-4b55-8232-6abd0fafb6b6.xml).
Info: Deleting filePath (MySite\MobileForms\Data\ea82749f-af9f-4d4c-acee-287ca1dd51d4.xml).
Info: Deleting filePath (MySite\MobileForms\Data\f8dfb3b5-08a3-4bfb-9a88-b02b1e39f63e.xml).
Info: Deleting filePath (MySite\MobileForms\Data\ffcff4f4-fc81-4e85-a100-a96d2ea85eca.xml).
I am pulling my hair trying to understand what's wrong.
I could spend time trying to understand what the hell is going on in msdeploy.exe using Reflector but that's just stupid. This was supposed to be something easy to do with msdeploy, why is it so complicated?
Can someone please say why is the regular expression not matching?
Thanks!
EDIT: See solution below!
silverbyte
23 Posts
Re: absolutePath regular expression matching in skip parameter for msdeploy
Oct 01, 2012 10:04 PM|LINK
richard.szal...
83 Posts
Re: absolutePath regular expression matching in skip parameter for msdeploy
Oct 02, 2012 09:02 AM|LINK
Your regex is fine, I'd guess there's something else at work. Can you try deploying without the skipAction property? It should skip them entirely. If not, something else is wrong.
silverbyte
23 Posts
Re: absolutePath regular expression matching in skip parameter for msdeploy
Oct 02, 2012 09:32 AM|LINK
I will try without the skipAction. But it does not make any sense. I need to give specific actions to skip. I do not want to skip all operations.
I tried many regular expressions, trying to understand the way matching works but without luck.
Matching MUST be RELIABLE! It's the skip rule based on which files are deleted! I am doing backup before deploying but I cannot afford to check each time I am doing the deploy on several sites!
If I am using 'MySite\\MobileForms', it looks like it works, it skips all files from MobileForms.
But I still have no idea why this works and not '.*\\MobileForms\\.*' or 'MySite\\MobileForms\\'
I spent some time digging in the Reflector.
msdeploy does use RegEx::IsMatch for matching the skip rule against the absolutePath.
However, I can't tell what is the actual value of absolutePath.
Is it the actual path ('MySite\\MobileForms\\Data\\ffcff4f4-fc81-4e85-a100-a96d2ea85eca.xml) ?
It clearly it is not, otherwise, my regular expression will match
Why there is absolutely NO words in the msdeploy documentation for how this thing works? Why does it have to be so HARD?
richard.szal...
83 Posts
Re: absolutePath regular expression matching in skip parameter for msdeploy
Oct 02, 2012 09:51 AM|LINK
It appears to me that there is simply a bug in how skips are handled on filePath entries when a skipAction is specified.
According to the docs (msdeploy -help skip):
You can avoid the bug by omitting the skipAction property when skipping files, but you'll need to be more specific about what files to skip. Alternatively, you can skip the parent dirPath without a skipAction and it will skip all the files within it (but it also won't upload any new ones).
silverbyte
23 Posts
Re: absolutePath regular expression matching in skip parameter for msdeploy
Oct 02, 2012 11:03 AM|LINK
I found it.
I hope this helps others as well.
There's no bug in msdeploy.
It does use regular expression against the destination object's absolute path. The regular expression is exactly like you give it, no mistique in that.
When deploying to my site, the absolute path is exactly how it appears in the output: MySite\\MobileForms\\Data\\MySite\MobileForms\Data\bd13954b-0cb3-41d8-ab8a-eb988ddb8ad1.xml
I found this by creating a custom deployment rule and with debugger attached, I saw how the regular expressions are kept in the defined skip rules.
The way skip rules are applied is based on the order of the synchronization operation(delete, update, add) is done on the actual object(directory or file).
For example, if there's a delete operation on the directory, the skip rules for files within the directory for the delete operation will NOT PREVENT files from being get DELETED!
In my case, the directory MySite\MobileForms get deleted entirely. The skip rule I set for the files is useless.
And for the directory, my mistake is in the regular expression:
-skip:skipAction='Delete',objectName='dirPath',absolutePath='.*\\MobileForms\\.*'
Should be:
-skip:skipAction='Delete',objectName='dirPath',absolutePath='.*\\MobileForms$'
which says that it should skip deleting directory path MobileForms(the first rule erroneously included slash in the regular expression).
In order to setup the skip rules correctly, it's important to have in mind the possible actions on the directories first.
Someone should update the documentation in MSDN for the -skip parameter to demystify the way skipAction works.
If you find more scenarios which might help in a clearer understanding of how the skip rules are applied, please reply so we all benefit from it.
silverbyte
23 Posts
Re: absolutePath regular expression matching in skip parameter for msdeploy
Oct 02, 2012 11:09 AM|LINK
By the way, I am not sure who is in charge with the web development on this site, but the message formatting absolutely sucks.
It's the worse I've seen.
When writing from Chrome, it does not take into account new lines.
In IE, new line works but not two consecutive new lines. I have to edit in HTML and add a br tag. This sucks.
I wonder how was this even released, it's a joke.
How can Microsoft have this on their IIS\ASP.NET forum site? Hello? Any leads\managers out there?
richard.szal...
83 Posts
Re: absolutePath regular expression matching in skip parameter for msdeploy
Oct 02, 2012 11:53 AM|LINK
I was actually going to point out that quibble in dirPath vs filePath, but after coming across the inconsistant behavior I assumed it was something else.
And don't get me started on these forums. I wish they'd just move to Stack Overflow.
sanjaysy123@...
1 Post
Re: absolutePath regular expression matching in skip parameter for msdeploy
Oct 25, 2012 12:10 PM|LINK
Hello,
I am facing similar issue. how do we skip deleting a file from secondary server. for example if i want to skip deleting test.html file from any folder.
i have updated the below rule in msdeploy.exe file and msdepsvc file
<rule name="SkipFile" type="Microsoft.Web.Deployment.DeploymentSkipRuleHandler" objectName="filePath" skipAction="Delete" absolutePath=".*\\Test.html"/>
but this is not working, when i sync the file is getting deleted. because this is not found in the primary server.
can anyone help us in resolving this issue
Thank you in advance
richard.szal...
83 Posts
Re: absolutePath regular expression matching in skip parameter for msdeploy
Oct 28, 2012 10:02 AM|LINK
Please ask this is a new, separate, question rather than continuing an existing, answered question.