[UTIL] Right-Click "Touch File" - Recycle that web app
We've been using external config files to manage separate dev.config / qa.config / prod.config settings for a while and it's worked pretty well. Pretty code sample here. The one difference here is that changes to the referenced external config files don't get picked up right away as web.config edits do, so we're always editing web.config to add / remove whitespace just so the ASP.NET application cache is invalidated and the app reloads, causing it to pick up the new config values.
What would be better is something like the unix touch command... from the right click menu...
I googled like mad and came up empty, so I decided to DoIt myself. While I was at it, I added a right click Backup function - it makes a copy of a file with .bak on the end - project.dll -> project.dll.bak, for instance.
Sadly, nothing fancy here - shell calls to the cmd copy function (you gotta edit it to command.exe if you're on Win98 / ME). The Touch command copies the file back over itself, giving it a new timestamp. The copy function checks for and prevents this, but it does support file concatenation so we just concatenate a nul. /b specifies binary mode which strips the null character, and /y says yes so you don't have to. And the best part - I'm really proud of this - it flashes the console window up on the screen to remind you of our glorious DOS heritage. Also because I couldn't figure out how to hide that. The Touch command is only added to config files, while the Backup command is added to all files (should I make Touch apply to all file types?). You can select multiple files and select Backup and it will get them all.
I've tested these a good amount, both locally and on mapped drives, but please blame Microsoft and not me if this eats your production web.config files. Let me know, though, so I can update this.
Or you can just save this text to a reg file and merge it:
Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\VisualStudio.config.7.1\shell\Touch\command]
@="cmd.exe /c copy %1+nul %1 /by"[HKEY_CLASSES_ROOT\*\shell\Backup\command]
@="cmd.exe /c copy %L %L.bak /by"[HKEY_CLASSES_ROOT\configfile\shell\Touch\command]
@="cmd.exe /c copy %1+nul %1 /by"
Epilogue: Just after finishing my masterpiece (see above), I saw that Steve McMahon (Mr. vbAccelerator) has done this before: vbAccelerator Touch Utility. If you haven't checked his site out lately, give it a look. Nice site, great stuff. I like my solution better, though - not just because it kept me up until 2 (at which point the baby woke up), but because mine is simpler, there's no exe file to accidentally delete, it takes 1/30th the disk space, and because Steve makes me feel stupid and I frankly resent it.