Wednesday, November 29, 2006

Post Build Aggravation on Vista

I really like a lot of things about Vista, and I know when I really start to understand it I will be singing the praises of this new OS. In the mean time I am just completely frustrated. My latest rant happened when I was trying to get my post build events working in Visual Studio. In the past I had always kept a "Projects" folder in the root that contained every project I was currently working on. When I moved to VS 2005 full time I decided to start keeping my new projects in the Visual Studio 2005\Projects directory. This seemed to work fine and even made backups easier as everything I did was now contained under "My Documents". Last week I moved to Vista and as I started getting back into some coding this week I spent a good day pulling my hair out over something really dumb.

I noticed that my post build events were no longer executing, and of course causing my build to fail. The post build events are a must because I was debugging some assemblies in our new Capture product that are late bound. I spent the first couple hours trying to figure out what had changed in my events (shown below).

copy $(TargetPath) "..\..\..\..\Application\bin\debug\Plugins\Win\$(TargetFileName)" /Y

copy $(TargetDir)$(TargetName).pdb "..\..\..\..\Application\bin\debug\Plugins\Win\$(TargetName).pdb" /y

This all seemed simple enough and worked fine with XP, but why did I now error with an exit code of 0? I changed the target directories to something very simple, like c:\temp and still no luck… exit code 0. The error messages were showing the full paths showing me that the directories seemed fine.

c:\users\chris.caplinger\Documents\Visual Studio 2005\Projects\KnowledgeLake\Capture\4.0\KnowledgeLake.Capture.Win

I took the commands being executed from the error message and decided to simply drop them into a command line window, and of course the copy failed. This made no sense as the directories were correct. I changed to the source directory and tried it again and Wham!, it worked. I have no idea on why this behavior is happening and figure it's probably a bug or a feature I could live without. After some more experiments I determined that the "c:\user" path is screwing everything up. Maybe this has something to with the new shadow folder since this used be "c:\documents and settings". I have just come to the realization for now that you can't copy stuff from paths in the "User" folder on the command line unless you are in that specific directory. And even then you won't be able to copy to other folders under "User".

The only fix I could come up with was to move all my projects back to "c:\projects", which resolved the problem and got me back on my way. Hopefully you get to read this before you spend several hours in frustration.

Chris

No comments: