views:

1117

answers:

10

I have a solution with several projects, where the startup project has a post-build event that does all the copying of "plugin" projects and other organizing tasks. After upgrading the solution from VS 2005 to VS 2008, it appears as though the post-build event only fires if I modify the startup project, which means my updated plugins don't get plugged in to the current debugging session. This makes sense, but it seems like a change in behavior. Is anyone else noticing a change in behavior with regard to which projects get built?

Does anyone know of a workaround that I can use to force the startup project to rebuild whenever I hit F5? Perhaps I configured VS 2005 to work this way so long ago that I've forgotten all about it ...

+2  A: 

I don't know if this is the right way to do it but you could add a prebuild event to your startup projcet (if it's static) to clean the project which will force a rebuild.

something like:

devenv project.csproj /clean
lomaxx
+2  A: 

Why not just add a dependency to the "startup" project for each of the plugins? This will force the project to be rebuilt if any of the others change, and you won't have to mess with any other pre/post-build events.

OJ
+4  A: 

I think you need to reorganize the responsibilities. Each component should be responsible for itself and therefore copy its generated goodness where it needs to go. That way it doesn't matter if/who/what/when/where got built. Whatever is updated will put itself into the proper place.


IMO the other suggestions are no-nos since they'll circumvent the compiler's smarts to know when a rebuild is necessary for the main project. And hence killing any compile time-savings. If your "plugin" projects are assemblies (and not just project-references from the main project), then you do not need to rebuild the main project each time a plugin is rebuilt. The new assembly will get selected into the process / debugger w/o the main project needing a rebuild.

xanadont
A: 

Should I assume no one else is noticing a change in behavior between VS 2005 and VS 2008? Maybe it has to do with the fact that the solution was "upgraded". I'm just grasping at straws here.

@xanadont: From where I sit, the startup project has the responsibility of making sure all the plugins are available to debug. If I move the post-build logic to each of the plugins, then I might get errors if the startup project hasn't been compiled or if I'm reusing the plugin project in a different solution without the startup project. Since I'm looking to debug them, my post-build event copies both the .DLLs and .PDBs so edit and continue works fine as long as the post-build event runs. This is just for running the debugger: my build server does all the proper organizing for deployment and testing.

flipdoubt
A: 

@OJ: Been there, done that. Thanks for the answer though. Adding dependencies (not references) to all the plugins worked in VS 2005, but it isn't working for me in VS 2008. That is why I'm suspecting some different configuration in the IDE or solution.

flipdoubt
+2  A: 

This is a pain. What we really need is for Microsoft to allow us to hook into a Post-Solution Build event. You can do this via macros but that's too complicated.

I'm assuming this is a C++ project because I don't have this problem with C#.

This is my solution, it's not elegant but it works:

  • Create a new project whose only purpose is to run the post-build script. Mark it as dependent on every other project in the solution.
  • Add a dummy file to that project called dummy.h or whatever.
  • Right click on dummy.h in Solution Explorer and select Properties.
  • Select 'Custom Build Step'.
  • For the command line type 'echo' and for Outputs just type 'dummy' or something else that will never exist.

This project, and therefore the post-build script, will now be run on every build.

John.

John Richardson
A: 

@John Richardson: Interesting, all the projects in my solution are C# projects. Are all your C# projects that work as they should new to VS 2008 or were they upgraded? I'm using SP 1, by the way. I will have to try that post-build project idea.

flipdoubt
+1  A: 

flipdoubt: they are projects created originally in 2008. My suggestion if it's not working C# is to look in the Build Events tab and check the setting of the "Run the post-build event:" drop down. If it is set to 'When the build updates the project output' this might be your problem, try setting to 'On successful build'.

John.

John Richardson
+1  A: 

I'm having the same issue here and it is VERY annoying. John Richardson is right in that there should be a Post-Solution Build event (and a Pre-Solution Build event) that applies whenever ANY project in the solution is being built.

I don't think there is any good workaround to get this outcome in the current VS 2008 IDE.

A: 

Starting from @lomaxx suggestion, I got a very similar setup working by adding the following line at the end of the post-build event of the startup project:

"$(DevEnvDir)devenv.exe" "$(ProjectPath)" /clean

Note that this makes the startup project build the next time you need to debug, so you should make sure the project gets built at least once.

PS. I initially tried the pre-build as suggested, but that didn't work (and I think it makes sense - if VS thinks a project doesn't need building, it won't execute any events for that project).

Cristi Diaconescu