1

Please hear me out as this question has been modified extensively.

I have an msbuild target that I want to execute after each project in my solution is built from the IDE. I can easily do this by creating an msbuild replica of my solution, but you can't use it within visual studio. You can go through the projects properies as specify an after build process, but this is quite tedious, especially if you have more than 2 projects.

Is there a better way to execute a target for all projects in a solution within the IDE? I just can't believe that VS2010 doesn't give you an easier option.

BTW, does VS 2012 Beta support a full MsBuild file instead of the brain dead solution file?

ATL_DEV
  • 9,256
  • 11
  • 60
  • 102
  • I'm confused by this question. Do you want to run it from the command line or visual studio? Solution files are _not_ msbuild scripts. – Ritch Melton Jul 14 '12 at 20:39
  • Thanks. I just edited my question for clarity. Correct, solution files are not build scripts, but MSBUILD turns them into a build script at runtime. I want to run the msbuild script inside VS 2010 seamlessly so that I can debug my application. – ATL_DEV Jul 14 '12 at 20:42

2 Answers2

0

What I get from your question is that you've extended the build process and then created a 'shadow' msbuild file that does what the solution file normally ends up doing during build. As you are aware, solution files are a rather unfortunate visual studio only concept. That issue is nearly impossible to work around.

The idiomatic approach to this problem is leave the solution file alone and modify the individual .csproj files to include the custom build steps that each project would need to be completed according to your process. NuGet does this when you use it, so does NotifyPropertyWeaver. (NuGet works around the solution issue by introducing a '$(SolutionDir)' property)

As an aside, I'm not sure how valuable 'building an installer' is to the individual developer on your team and including in the build seems like it adds friction rather than removes it.

If this is for a custom build server, there's no need to use the solution file at all if you don't mind keeping the two in sync and I'd wholeheartedly recommend that approach.

Ritch Melton
  • 11,498
  • 4
  • 41
  • 54
  • Thanks Rich. I don't necessarily want to run my msbuild file, I just want it to execute the most important target which is to do an optimize release build and move the plugins into a folder inside the application folder. When I hit the run button, I want it to execute the main application from the final output folder. Right now I am manually copying the plugin files into a plugins directory and then running the debugger. – ATL_DEV Jul 14 '12 at 20:58
  • Ok, you can do that in many ways. Modifying the project file, or adding them to the project and selecting 'Copy to Output Folder' are two. The solution file is a red herring. – Ritch Melton Jul 14 '12 at 21:04
  • I just edited my question again. Thanks for being patient with me. You're getting very close to my answer. My plugins are already in the project. I am already using copy to output folder, but I wish I could write a global target that would automatically do this for me based on a criteria. – ATL_DEV Jul 14 '12 at 21:12
  • Where does the debugger run from? Is there a way to set that through a target? – ATL_DEV Jul 14 '12 at 21:13
  • I really don't know how the debugger gets its info, but I'd assume that its hardwired in visual studio to use the project output. – Ritch Melton Jul 15 '12 at 01:40
  • I don't see why you can't use the configuration manager to specify your criteria using PropertyGroups and conditions. It still comes down to leaving the solution file alone and modifying the project files. – Ritch Melton Jul 15 '12 at 01:41
0

You can debug msbuild using the visual studio IDE. There is an undocumented registry switch to enable. See this thorough msdn article:http://blogs.msdn.com/b/visualstudio/archive/2010/07/06/debugging-msbuild-script-with-visual-studio.aspx

James Woolfenden
  • 6,498
  • 33
  • 53
  • Thanks, but unfortunately, I'm not having problem with msbuild. I am trying to get Visual studio to run my build scripts. – ATL_DEV Jul 19 '12 at 14:00