Ben Vanik

I've been working on my first large XNA project and am finding that building my projects takes forever. I have both my Windows and 360 projects in the same solution, and there are 5-6 projects each. Normal setups like this in Visual Studio are a incredibly quick to build on average, but with GSE I notice that it seems to be invoking MSBuild for every project regardless of the solution configuration or dirty state. For example, if I have platform set to x86, my build output window still scrolls the 360 projects, each one taking 1-2 seconds to find out it's not set to build. Worse yet, it does this for every project, every time I build, even if I just made a one line change in an assembly with no dependencies; builds take 25-30 seconds!

My (lame) solution was to split the solution up and have one for Windows and one for 360, cutting the build time in half. It's still annoyingly long though (at least for a veteran .NET developer - I've been used to 1-5s builds for the past 5 years :) because it invokes MSBuild for every project regardless of whether or not it changed. Is there any way to get VC# to not invoke MSBuild if there were no changes It wouldn't be so bad if the apparent overhead wasn't so high. Since I'm not sure there's a nice solution that I could do, should I create a feedback item for this

 

Does anyone else have any tricks they are using to speed things up I doubt I'm the only one who likes having more than just one assembly :)

 

EDIT: one nice speedup I found was converting some of the Windows projects I knew weren't going to use the content pipeline to normal .NET class libraries.



Re: XNA Game Studio Express Build speed with many projects

Stephen Styrchak - MSFT

Hmm, to me, this does sound like a bug. Please enter it into Connect, and please submit your project as a repro case (if you're willing). Otherwise, try to provide details of what kinds of projects and what they are for -- Xbox 360/Windows games, custom processors, and the inter-project dependencies, etc.

Regarding workarounds to maybe speed things up, you could try setting the option to only build startup projects and their dependencies on run (F5). If you're actually building the solution each time, then it won't make a difference, but if you're typically making a change and then launching the debugger with F5, then it will probably speed things up. This option is enabled on the Tools | Options dialog. Check "Show all settings", then select Projects and Solutions | Build and Run. Check the box that says, "Only build startup project and dependencies on Run".

--Stephen





Re: XNA Game Studio Express Build speed with many projects

Ben Vanik

Thanks for the response!

There are two problems, I guess. The first is that projects have a lengthy MSBuild invoke even if nothing changed, and the second is that projects that are configured to not be built still have get MSBuild invoked on them.

Simple illustration of the first problem (I'd consider it bad behavior more than a bug :) - this is the 5th build of the Client project in a row - I just hit build project on it several times in a row:

------ Build started: Project: Hiranipra.Utilities.X360, Configuration: Debug Xbox 360 ------

Hiranipra.Utilities.X360 -> C:\Cache\Dev\Hiranipra\trunk\Hiranipra.Utilities.X360\bin\Xbox 360\Debug\Hiranipra.Utilities.X360.dll

<....snip several other projects...>

------ Build started: Project: Hiranipra.Client.X360, Configuration: Debug Xbox 360 ------

Hiranipra.Client.X360 -> C:\Cache\Dev\Hiranipra\trunk\Hiranipra.Client.X360\bin\Xbox 360\Debug\Hiranipra.Client.X360.exe

========== Build: 9 succeeded or up-to-date, 0 failed, 0 skipped ==========

Each one of those steps takes about 4-5 seconds to figure out nothing changed. Why I'm thinking this is all just useless overhead is because one of the projects doesn't have a single file in it, yet it still takes ages.

The second issue, upon inspection, may be a bug, as I haven't been able to replicate the behavior on my laptop. I'll try reinstalling VC# in the morning.

Thanks again for the response!





Re: XNA Game Studio Express Build speed with many projects

Shawn Hargreaves - MSFT

There are a couple of known issues that make the build slower than it would ideally be, especially when there are a lot of projects in the solution.

We'll hopefully get these fixed for the next release.





Re: XNA Game Studio Express Build speed with many projects

Jim Perry

Shawn Hargreaves - MSFT wrote:
We'll hopefully get these fixed for the next release.

Which will be when exactly !

Yeah, I'm not expecting anything.






Re: XNA Game Studio Express Build speed with many projects

Lostlogic

I see the same thing actually with just the default wizard builds (windows game and xbox game.) VC++ compiles many times faster with the same "amount" of code represented. Either C# builds are incredibly slow compared to C++ or something is up with GS.




Re: XNA Game Studio Express Build speed with many projects

Nick Tuckett

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.





Re: XNA Game Studio Express Build speed with many projects

Shawn Hargreaves - MSFT

I'm surprised you're seeing quite that dramatic an overhead from building inside VS (my builds aren't anywhere near that slow) but that seems like a great way to work around it.

You'll be pleased to know that we've been working on some fixes that will speed up all content building quite dramatically, especially for the cases where nothing has changed, and make building inside VS just as fast as externally. So the next version will be dramatically faster in this regard.





Re: XNA Game Studio Express Build speed with many projects

waruwaru

I notice my project had this setting on

I found this setting in Tools->Options that I didn't notice before that may be causing everything to compile. Try turning this on if your projects appear to build for no reasons:

Tools->Options->Show All Settings check box in lower left->Project and Solutions->Build and Run->make sure the "Only build startup projects and dependencies on Run" check box is checked.

I don't remember turning it on. So maybe it's default to be on (sorry, can't verify right now) Turning it off by default would help some.






Re: XNA Game Studio Express Build speed with many projects

Nick Tuckett

 Shawn Hargreaves - MSFT wrote:
I'm surprised you're seeing quite that dramatic an overhead from building inside VS (my builds aren't anywhere near that slow) but that seems like a great way to work around it.

You'll be pleased to know that we've been working on some fixes that will speed up all content building quite dramatically, especially for the cases where nothing has changed, and make building inside VS just as fast as externally. So the next version will be dramatically faster in this regard.

That's good to hear!

Will this work also improve code build speed My test project only has one font and three simple shaders, so its building much more code than content!

 





Re: XNA Game Studio Express Build speed with many projects

Nick Tuckett

Here's a link to MSBuild command line reference on MSDN online: http://msdn2.microsoft.com/en-us/library/ms164311.aspx

Worth checking out if you try my workaround; there's quite a lot you can pass to tune the behaviour and output of MSBuild.

 





Re: XNA Game Studio Express Build speed with many projects

Shawn Hargreaves - MSFT

Nick Tuckett wrote:

Will this work also improve code build speed My test project only has one font and three simple shaders, so its building much more code than content!



The C# code build is already extremely fast.

Most of the content building optimisations we made since release are to do with fixed overhead costs (setting up worker AppDomains, loading the various processor assemblies, etc) rather than the actual work of building the content, so these will give a constant speed boost regardless of how much content there actually is in the project.





Re: XNA Game Studio Express Build speed with many projects

Nick Tuckett

I've been using my MSBuild "workaround" for a few weeks now, and have only come across one side effect so far. Namely if you add a new source file to a project, you need to make sure that the .csproj file has been saved before you try a build, otherwise your new file won't be compiled. While source files themselves get automatically saved, the same doesn't seem to happen for project files.

Not saving can lead to curious errors, e.g. if you add references to your new class in an already existing file, they will be reported as not found in their context.