Preface: For my new version of WebDeploy, I wanted to disband the idea of using extensions. Now, don't freak out...I have a good reason why. One of the most pressing requests has been
"How can I copy config-prod1.config to my production server 1, config-prod2.config to my production server 2, but not deploy config-prod2.config to production server 1?"
Well, my normal answer was, use the "Files to be Copied" dialog to exclude them, as well as rename as you wish. So, do you see where I'm going? I sure hope so.
Post: My main problem, as you can see, has been, how do I implement this into WebDeploy without changing the focus of WebDeploy immensely. Well, the answer wasn't so simple until I was chatting with my good friend Ryan about this problem. His first suggestion was to use the overloaded method of GetFiles to include a mask instead of just retrieving all files.
As this point it seemed like a perfect solution. Oh, but as I started to look into it more, I determined that this just wasn't going to work, primarily for when a source is a VS.NET project file. There's no way of using GetFiles with the mask overload against that, so we went back to the drawing board.
What we came up next was a meeting of the minds that only the statement "Great minds think alike" can explain (which I might add was noted after we both posted the same idea). Well, this idea, of course, was to use Regular Expressions to match the mask. Great idea, huh...did you think of it too?
So, I then proceeded with "how am I going to convert the mask supplied to WebDeploy into a regex that will match file names." Oh, the answer was so simple yet ungodly weird. So, we had to go from something like:
config-*.config
and have it converted into a regex that will match my examples in the preface. It seemed all too simple, but I realized that * isn't a wild card character, rather . (period) was...and so I transgressed into a regex formula that will need to take place:
1) Convert any non alpha-numeric char's (aside from *) into \[char]
2) Convert any *'s into .*
3) Prepend ^
4) Append $
which, after the logic processes takes the mask and creates:
^config-.*\.config$
running the regex through a matcher matches both file names noted in the preface without a hitch.
Now, I'm not really sure what the wildcard logic to match files or folders looks like in [enter wildcard matcher here], but I think this is a pretty good solution. If you find anything wrong, please let me know as this logic will be put into WebDeploy. If you find some better method, please let me know as well, any and all help will be greatly appreciated.
Conclusion: Both Ryan and I feel that this new "masking" concept will make WebDeploy a much more powerful tool, allowing you to copy matched files instead of just files with that extension.
"Let the beast roar with great functionality. Because only then can you find out if its worth your time." - Matt Hawley
cfcc0347-d815-4160-b6b3-59528d667bcd|0|.0