SyntaxHighlighter

Friday 19 July 2013

Day 29: Return of MSBuild

...and I worked out what the MSBuild problem was. It wasn't recognising the assembly Microsoft.Xna.Framework.Content.Pipeline.dll apparently because I was using the wrong public key token.
Success is the ability to go from one failure to another with no loss of enthusiasm.
Opened that sample code on Winforms, and noticed they were referencing the same assembly actually within the code, and then noticed that they were using a different public key token to the one I had specified. Copy pasted their token and boom! MSBuild now recognises the BuildContent task and the fbx starts building!

So new error:
MSB4044: The "BuildContent" task was not given a value for the required parameter "TargetProfile".
 Fixed by adding the parameter TargetProfile="HiDef" in my proj file.

Next error:
1.fbx : error : Cannot autodetect which importer to use for "t1.jpg". There are no importers which handle this file type. Specify the importer that handles this file type in your project.
This happens after it starts seemingly correctly importing and processing 1.fbx (the fbx file I told it to process). 1.fbx references the texture t1.jpg which is intended, and I've placed the texture in the same directory as the model so it can see it. Now I need to somehow tell MSBuild to use Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll, as well as the TextureImporter and TextureProcessor pipelines. How on earth am I going to do this... so this is the current project file:
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <UsingTask TaskName="BuildContent" AssemblyName="Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553" /> 
    <PropertyGroup> 
      <XnaInstall>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86</XnaInstall> 
    </PropertyGroup> 
    <ItemGroup> 
      <PipelineAssembly Include="$(XnaInstall)\Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll" /> 
    </ItemGroup> 
    <ItemGroup> 
      <Content Include="1.fbx"> 
        <Importer>FbxImporter</Importer>   
        <Processor>ModelProcessor</Processor> 
      </Content> 
    </ItemGroup> 
    <Target Name="Build"> 
        <BuildContent SourceAssets="@(Content)" PipelineAssemblies="@(PipelineAssembly)" TargetPlatform="Windows" TargetProfile="HiDef" /> 
    </Target> 
  </Project>
So I want to include TextureImporter.dll in the PipelineAssemblies.

Welp, try the obvious (added line 8):
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <UsingTask TaskName="BuildContent" AssemblyName="Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553" /> 
    <PropertyGroup> 
      <XnaInstall>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86</XnaInstall> 
    </PropertyGroup> 
    <ItemGroup> 
      <PipelineAssembly Include="$(XnaInstall)\Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll" />
      <PipelineAssembly Include="$(XnaInstall)\Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll" />
    </ItemGroup> 
    <ItemGroup> 
      <Content Include="1.fbx"> 
        <Importer>FbxImporter</Importer>   
        <Processor>ModelProcessor</Processor> 
      </Content>
    </ItemGroup> 
    <Target Name="Build"> 
        <BuildContent SourceAssets="@(Content)" PipelineAssemblies="@(PipelineAssembly)" TargetPlatform="Windows" TargetProfile="HiDef" /> 
    </Target> 
  </Project> 
...
There are moments when everything goes well; don't be frightened, it won't last. 
Which is almost exactly what we needed, except that in LowryDemo it expects the model to be named 1.xnb and not 1_0.xnb. Annoying, but we can simply rename every model that comes out of this MSBuild and it will work straight off. At least the texture is correctly named t1_0.xnb texture.

What we have so far

Right, so here's a quick lowdown:

if our incoming folder contents changed (i.e. files arrived)
get names of new files (this is hard for some reason)
(perhaps copy new files to another folder to get processed so we don't lose the originals)
want to rename the files to the next incremented integer to ensure we dont miss any heads (1.fbx, 2.fbx etc)
want to rename any new .jpg file: cut off  "_tex_0", add a "t" so 1_tex_0 .jpg becomes t1.jpg
want to enter any new .fbx file and replace the regex stuff.
build the .fbx to .xnb
copy paste into lowrydemo program folder
load next head.

The renaming can all be done using sed, as well as the regex replacement within fbx files (tested regex replacement sed command, all seems to work perfectly). The build of fbx to xnb has been sorted too now that I've enforced my will upon MSBuild.

One issue now is what should really be the "easy" bit, just the general moving files around. Getting the names of the new model and texture and then transporting them to be built by MSBuild, transporting the .xnb's to the correct folder inside the bowels of LowryDemo's content and stuff like that.

The more important issue is how to deal with loading the compiled xnb files into the AR demo (LowryDemo) program. The current placer heads and copy pasting xnb's can be automated but it's a bit fiddly so I'm looking into content pipeline extensions as well.

Another reinstall

There was an issue with activating the Windows 7 install on Katy, Donald, Walter and Hoops. In order to fix it we are going to reinstall the PC's with an On Campus version of the 64bit Windows 7 disk image provided by the University.

So yes, starting with Donald I'm going to be reinstalling absolutely everything... again. Sounds like fun! I'm so good at this now I can probably write a script that presses the correct keys at the correct seconds to completely automate the install of Windows, Visual Studio, Goblin XNA, 3DS Max, Camtasia, etc..

No comments:

Post a Comment

Note: only a member of this blog may post a comment.