5

I just recently upgraded from VS2008 to VS2010. Because I do a lot of remote debugging (over VPN), I use Post-Build events to copy the compiled binaries and PDB's to the target machine before running. I do this by calling a batch file that (among other things) executes Robocopy.

In VS2008, the Output panel would display robocopy's output in realtime, i.e.:

5>          Newer             421376    RadarController.pdb
5>    0%  
5>   14%  
5>   29%  
5>   43%  
5>   58%  
5>   72%  
...

However, in VS2010, rather than showing the Post-Build event's progress little by little, it simply locks up until the entire event is complete - then the output all appears at once. This is a particular problem when copying over a slowish net connection, as I have no idea what's going on for potentially minutes at a time. There's no way to guess if the copy will go on for 5 seconds or 5 minutes; I wouldn't even know it was copying, if I wasn't already familiar with the order of the compiler events.

Is this a known bug in 2010, or does anyone know of an existing workaround?

Thanks!

Edit 1: The project is C#.

Edit 2: The exact Robocopy command I'm using is robocopy.exe . \\192.168.5.7\Release /NJS /NJH /Z /W:1 /R:5 /E

J23
  • 3,061
  • 6
  • 41
  • 52
  • 1
    we are experiencing the same issue. So far I have found these two issues on connect which describe it, but unfortunately MS is not responding to them - perhaps if we upvote them a bit more: https://connect.microsoft.com/VisualStudio/feedback/details/566899/ and https://connect.microsoft.com/VisualStudio/feedback/details/593873/ – Tuinstoelen Oct 26 '10 at 14:43
  • 1
    I found one more issue on connect describing this issue: It looks like they are not going to fix it.... Url: https://connect.microsoft.com/VisualStudio/feedback/details/561075/build-window-hangs-on-long-post-build-event – Tuinstoelen Oct 26 '10 at 14:48
  • Good finds - I voted both up, and added to "User(s) can reproduce this bug". Looks like I'll have no choice but to stick with 2008, though...sad they've chosen to ignore it :( – J23 Nov 03 '10 at 07:53

3 Answers3

2

Considering it appears like MS does not want to fix this issue soon, and us still wanting to move forward to VS.NET 2010, we've devised the following workaround. It is not ideal but good enough for us.

Most of our long running post-build events we only run when building for release, not during general software development. So on those occasions we run those events in an external command window so we can monitor the progress.

We use the unix tee command (grabbed of the net somewhere) to add the output into the output window after the script has completed.

In the postbuild event we have:

@@echo off
cd "$(ProjectDir)"
START /WAIT cmd /c PostBuildStub.cmd "$(SolutionDir)" "$(ProjectDir)" "$(TargetDir)" "$(SolutionPath)" "$(ConfigurationName)" 
ECHO PostBuild output:
TYPE $(TargetDir)postbuildlog.txt
ECHO Done.

So the postbuild event starts the external cmd window and dumps the log file into the output window when done.

PostBuildStub.cmd looks like this:

@echo off
echo.

set SolutionDir=%~1
set ProjectDir=%~2
set TargetDir=%~3
set SolutionFile=%~4
set ConfigurationName=%~5

CD /D "%ProjectDir%"

CALL PostBuild.cmd %1 %2 %3 %4 %5 | "%SolutionDir%\bin\tee.exe" "%TargetDir%\postbuildlog.txt"

if errorlevel 1 exit 1

The postbuild stub creates the log file by calling the real postbuild commands and piping the output to both the cmd window and a log file.

Then in the PostBuild.cmd we have our good old postbuild commands which do the resource compiling, ilmerging, obfuscating, signing or whatever you need :)

Tuinstoelen
  • 1,221
  • 10
  • 8
  • Cool, nice workaround :) I think personally I'll be sticking with 2008 though. I'm not particularly interested in shelling out > $500 for an "upgrade" if they can't even be bothered to provide a reasonable fix. – J23 Nov 25 '10 at 01:37
  • This work-around does not work for me; it still keeps the Visual Studio IDE busy\unresponsive during the PostBuild event. :( – Rami A. Jul 07 '11 at 04:11
  • Rami: That's correct - the Visual Studio IDE is blocked during the running of the script, but at least now you can see how your script is progressing. – Tuinstoelen Jul 08 '11 at 20:51
1

It does pretty much the same thing for me. I have a post-build step that consists of ILMerge and then a DOS move command. The ILMerge output is never shown, but the output from move is. I submitted a bug on http://connect.microsoft.com, ID 613727.

DocKell
  • 441
  • 6
  • 7
1

I am wondering if using an msbuild <exec> task instead of a post-build event would resolve this issue?

If the <exec> task does not meet your requirements, maybe a custom msbuild task that does something similar to the <exec> task would resolve the issue for example.

Update:
I just tried using <Exec Command="" /> instead of a PostBuild event in my msbuild file but it still kept the Visual Studio IDE busy\unresponsive.

Maybe we can create a custom msbuild task that calls Application.DoEvents to keep the UI responsive?

Update #2: I uploaded a patch to MSBuild Extension Pack that implements a custom msbuild task called SmartExec that works around this issue.

http://msbuildextensionpack.codeplex.com/workitem/9053
http://msbuildextensionpack.codeplex.com/SourceControl/list/patches
Patch Id 9878

Rami A.
  • 10,302
  • 4
  • 44
  • 87
  • It has just been committed as part of Change Set 69252 – Rami A. Aug 24 '11 at 01:21
  • Personally I ended up just sticking with VS2008, due to this and several other bugs that 2010 introduced. Didn't seem worth paying for an upgrade that resulted in a regression. Looks like you actually managed to fix it up tho, so answer definitely accepted! :) – J23 Mar 24 '12 at 18:42
  • This is an old post, but for posterity, I thought I would note that this change has since been integrated into the latest builds. – Jeff Walker Jun 06 '12 at 14:02
  • @JeffWalker latest build of what? I'm using VS premium 2013 and it has the same bug. Long running post-build events do not update the Build Output console until it is completely done. As a result it seems to be hung. – John Henckel Nov 10 '15 at 15:36