tags:

views:

802

answers:

3

Hello,

I've been trying to use TeamCity 4.5 in order to automate builds of an XNA project but I have a small problem. My projects compile correctly under Visual Studio 2008, but not when compiled with TeamCity as the builder. The configuration file uses the sln2008 setting, and compiling goes well for a while, but as soon as it goes compiling .png textures to .xnb, I get the following error:

[11:28:41]: [Project "Content.contentproj" (default targets):] Content\head.png Building content threw InvalidOperationException: D3DERR_INVALIDCALL
at Microsoft.Xna.Framework.Content.Pipeline.CommonHelperFunctions.InitD3D()
at Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.InitD3D()
at Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.Import(String filename, ContentImporterContext context)
at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.ImportAssetDirectly(BuildItem item, String importerName)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.ImportAsset(BuildItem item)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild()
at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary`2& dependencyTimestamps, KeyValuePair`2[]& warnings)
Inner exception: COMException: Exception from HRESULT: 0x8876086C

I do not have any ideas what is causing this. Like I said, it's able to compile .fbx models correctly as well as my ContentPipeline project and my SharedContent project (part of the solution).

What I would actually like is some pointers to what would be the source of the problem (and if possible, a solution to the problem). As far as I understand, there seems to be a problem with the D3D library. I will also remind you that this whole solution compiles under Visual Studio 2008, thus there is a small problem with TeamCity, either I haven't provided something, or something is actually incorrectly set.

+2  A: 

I don't have a solution but I've been thinking about it.

The error is D3DERR_INVALIDCALL so I'm thinking the device isn't available at that time for some reason.

1) Do the machines running the build have DirectX installed/a graphics card? I'm assuming yes since XNA requires a card with shaders but TeamCity is a build distribution so maybe it's running on a machine without it?

2) Maybe TeamCity is causing too too many Direct3D devices to be created on the same machine/process (complete guess)?

Do the model files that compile correctly use textures or are they just geometry data? I have a feeling the content builder doesn't need access to DirectX to build models but does for texture data. Can you build anything else that requires access Direct3D? Can you build a project using TeamCity that just has one texture in it's content folder?

I'm not sure if this would work but can you get more information by running DirectX in Debug Mode and looking at the output?

Hope this helps somewhat.

Kath
I would go for (2). As a solution to (1) he could install the DX SDK - it has the reference device, which wouldn't cause these problems.
Jonathan C Dickinson
@Kath: Thanks for the reply. I forgot to specify that both the server and build machines are the same, thus 1 can be removed from the equation.With DirectX in debug mode, I get a Process exit code: -2146233082.I have made a small project consisting of only an image and the basic Game project and without the image, it does compile, with it, it does not.
tomzx
+1  A: 

Almost certainly, Team City is running it's build process as Local System in a non-interactive mode, and not as a user that actually has the access and ability to grab the graphics device. I know I've had problems even attempting to batch process textures through a Remote Desktop interface because DirectX can't grab the graphics device.

The solution may be to see if Team City offers you the ability to request that it's builder run as a logged on user, not as Local System, or as a service, though I can't tell you that that's actually even possible in Team City.

Jeff
@Jeff: Thanks for the reply. I actually went ahead and changed the user which the service uses to log in. The problem is still the same, though I believe it's now related to something called "Hardware profile" in the service properties. I seem to only have an "Undocked Profile" (probably still no access to the graphic card, it's hard to tell). Also, this Hardware profile doesn't look like it can be edited from somewhere else (I googled it and it returned many people complaining about it)
tomzx
+2  A: 

XNA and DirectX 9 require a current logged in user in order to compile the Content folder.

The solution is simple, set up a build agent machine (real physical machine) with the pre-reqs for XNA (VS2008, XNA Game Studio 3.0, etc) and make it log in on startup, then create a script to run the team server agent when logged in (by placing a shortcut to the agent run script in the start up folder in the start menu).

This way the agent will run as the local user and can build as normal.

I have done this and can confirm that it works.

Ezz