I discovered that MSBuild can be used outside of GSE to build XNA projects and their data, and decided to time it against building within GSE. This was while trying to use CruiseControl continuous integration on an XNA project ... just for the hell of it!
Within GSE, my solution consisting of 41 source files across four projects takes on average 15 seconds to do a full rebuild. A build with no changes after this takes on average 14 seconds, which is a ridiculous amount of time just to work out that there's nothing to do.
Running MSBuild on the solution from the command line takes on average 7 seconds for a full rebuild and 5 seconds for a "do nothing" build. It also times the build itself!
I decided to take advantage of this through the "External Tools" facility of GSE, and create two custom buttons for MSBuild - one for a normal build, and one for a full rebuild. Here's a step-by-step guide if you want to try it yourself:
- Click on Tools -> External Tools.
- In the dialog that opens, click on the Add button.
- Type a title into Title - e.g. MSBuild.
- Type the path to MSBuild.exe into Command; something like C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe
- Type $(SolutionFileName) into Arguments (or use the button to the right of that field to pick it).
- Type $(SolutionDir) into Initial directory
- Check Use Output Window
- Click OK
To test the tool, click on Tools -> MSBuild and you should find it does a debug build of your solution. For me, that achieves the faster times recorded above from within GSE. For greater ease of use, you can use Tools -> Customise to add this tool to an existing toolbar, or even create a new one for it.
You can pass command line parameters to MSBuild to select the configuration (e.g. if you wanted to do a release build, or a 360 build) or force a rebuild, amongst many others. There's a lot of material on the web and in MSDN that will give you the low-down on that. For example, to force a rebuild add /t:rebuild to the arguments in the steps above.
The build output is different to the normal GSE build, but still readable. You can still click on errors and have them come up in the editor, but they don't appear in the error list. I imagine there may be some ways to reformat it via command line options and/or some sort of plugins.
Unfortunately if you make a build this way and then try to launch the debugger, GSE will perform a build pass prior to entering the debugger. This puts us right back where we started, and in my case means a 14 second wait for the debugger to launch. However, there's a nifty way around it:
- Click on Build -> Configuration Manager
- Select <New...> in the drop down for Active Solution Configuration
- Type in a name such as Fast_Debug
- Select Debug in the Copy settings from drop down
- Make sure Create new project configurations is not checked
- Click OK
- The configuration manager should now show your new solution configuration as the active one, and list all the project in the solution, with configurations set to Debug.
- Uncheck each project's checkbox in the Build column.
- Click Close
You now have a debug configuration that will do nothing if you try to use the normal GSE build, but will build fine with your shiny new MSBuild external tool. What's more, if you launch the debugger via F5 or Debug -> Start Debugging it will fire up almost immediately, and not go through the "do nothing" build step for each project.
The drawback to this approach is that you have to manually build any changes before debugging. For me, that's a very small price to pay in comparison to the build time and debugger launch time savings.