Feb 2006 (1)
Aug 2005 (1)
Jul 2005 (1)
Jun 2005 (2)
May 2005 (2)
Mar 2005 (1)
Jan 2005 (1)
Oct 2004 (3)
Sep 2004 (1)
Aug 2004 (1)
Backing up a source file with post build events
VS.NET 2003 is amazing but not without its faults. Those that spend a good part of their day using the designer are all to familiar with the InitializeCoponent bug in ASP.NET and the infamous disappearing controls bug in Windows Forms (which still happens even with the hotfix). Both of the bugs are designer related in that they butcher the code in InitializeComponent. I've finally cobbled together a workaround and thought I’d share it. It’s a little ugly but it works.

I started off with source control but that almost tripled the # of check-ins I had and made rolling back a bit of a pain. My alternate solution is below. The post build event (batch file) will copy the file of our choice to the location of your choice and append a timestamp to the end of it. It may seem like overkill to copy the file after each build but I can tell you that it’s been a huge time/frustration saver.
for /F "tokens=2,3,4 delims=/ " %%i in ("%date%") do set FileTimeStamp=%%k-%%i-%%j_
for /F "tokens=1,2,3 delims=:. " %%i in ("%time%") do set FileTimeStamp=%FileTimeStamp%%%i-%%j-%%k

COPY "$(ProjectDir)MainWindow.cs" "$(TargetDir)\Backup\MainWindow_%FileTimeStamp%.cs" /Y
To use the script above replace MainWindow.cs with the name the file to backup and $(TargetDir)\Backup\MainWindow with the directory and file name to backup up the file to.

Alternatively, if you follow these strict usage guidelines you might not encounter the problem at all. Talk about working in a box.

UPDATE

Microsoft released hot fixes for the Windows Forms issues! See how they fixed Windows Forms designer bug here. But don't jump for joy just yet, you have to contact MS support for them. WTF?! ...

Posted Jan 01, 2005 @ 11:30 AM | Comments: 1

Comments

ravinder (6/6/2008 11:15:55 AM)
  Hi

Thanks for the useful info that you provided us with. We hope that that our users too will find this info useful. By the way this is the official site of binarysemantics : http://www.binarysemantics.com/ that software services in Outsourcing custom software web application Development

Post Comment
  User:
  Comment: