Vasura

Hi,

I'm loading files from a windows form test application and I want to load XACT audio assets, but my idea was to ask the user only for the xap project filename, generate the files into a folder in run time and then simply load all the generated data according to the extensions. I've been doing MSBuilds for other standard importers, but I just can't find the names for the importer and the processor. My documentation shows N/A when it comes to XACT projects.

Any idea   

Thanks!



Re: XNA Framework XAP Importer

Shawn Hargreaves - MSFT

The XACT build process is a bit different to other kinds of content, because we had to sit on top of how the standard XACT tools work, rather than building it from scratch inside our importer/processor framework.

For XACT, there is a separate MSBuild task in the same namespace as the regular content pipeline one. It works in a similar way: you give it the list of .xap files to build, it does incremental checks and returns item lists holding the names of the output files.





Re: XNA Framework XAP Importer

Vasura

Alright, I think I've got it, I just need to use the BuildXact task instead of BuildContent, right

I'll give it a try tomorrow. I'll post back if I run into problems :)

Thanks Shawn!





Re: XNA Framework XAP Importer

Vasura

Hi again,

BuildXact did the job, but I kept thinking about those returning list of files and I seem to be unable to get them, I simply don't know how to write the parameters in the task to return the values.

I create the xml in run time and then I call BuildProject, like this, but I never get a proper output:

Project project = new Project(buildEngine);

project.LoadXml(stringBuilder.ToString());

Dictionary<string, ITaskItem[]> outputs = new Dictionary<string, ITaskItem[]>();

string[] targets = new string[numTargets];

targets[0] = "Build";

buildEngine.BuildProject(project, targets, outputs);

I've been using BuildContent task to try this. By the documents I read, there should be an OutputContentFiles properties I could use. I tried to use a <Output ItemName="whatever" TaskParameter="OutputContentFiles"> section in the build target, but I cannot find the right sintaxis (that's if this is the way to do it, of course).

I tried this and almost every combination/variation of these lines I can think of:

<Target Name="Build">

<BuildContent SourceAssets="@(Content)" PipelineAssemblies="@(PipelineAssembly)" TargetPlatform="Windows" />

<Output TaskParameter=OutputContentFiles ItemName=OutputFile />

</Target>

 At some point I also tried to add <CreateItem> to the mix, with no luck. I couldn't find any sample I can use... and I've been looking, I swear on my over-tabbed explorer :)

 

 

 





Re: XNA Framework XAP Importer

Shawn Hargreaves - MSFT

That looks basically right, but the Output tag needs to be nested inside BuildContent:

<BuildContent SourceAssets="@(Content)" PipelineAssemblies="@(PipelineAssembly)" TargetPlatform="Windows">
<Output TaskParameter=OutputContentFiles ItemName=OutputFile />
</BuildContent>







Re: XNA Framework XAP Importer

Vasura

Jezz, I had already tried that, but I left the "/" in the closing "/>" for BuildContent and got some nasty error. My bad :(

It looks fine now. Thanks Shawn! 

EDIT: Well, more trouble... the Task seems to be doing fine, but I still cannot retrieve the output. It looks always empty. To ensure it wasn't a problem with incremental build, I flag the RebuildAll and I'm trying to get both OutputContentFiles and RebuiltContentFiles, just in case.

Once again I couldn't find any sample to get this done, BuildProject related docs seems to be almost non-existant. I found a post in the MSBuild forum where someone had the same problem, but it doesn't explain how he managed to make it work.

This is the code. Any ideas (thanks!)

IDictionary outputs = new Hashtable();

string[] targets = new string[] { "Build" };

buildEngine.BuildProject(project, targets, outputs);

foreach (DictionaryEntry de in outputs)

{

string myTarget = de.Key.ToString();

foreach (ITaskItem task in (ITaskItem[])de.Value)

{

 // task is always null, value seems to be empty

}

}





Re: XNA Framework XAP Importer

Shawn Hargreaves - MSFT

Hmm, you're way out of my depth here I'm afraid!

I've used the output parameter values elsewhere in my MSBuild project before, but never tried reading them back into C# like this. Your code looks ok as far as I can guess from the docs...





Re: XNA Framework XAP Importer

Vasura

Thanks for the reply.

I still haven't figured this out... I'll try once again, this time with the BuildXact task, just to see if that makes any difference and if the problem persist I might post a message on the MSBuild forum. I'll post back the solution as soon as this work...





Re: XNA Framework XAP Importer

Vasura

And back to square one. I cannot spend as much time as I wish on this on weekdays and it's taking me ages to get this right...

I've been trying to work with BuildXact, but that's failing too. I'm not trying to retrieve any output parameter yet, it's just the MSBuild won't work. I cannot figure out what's wrong here (this is an excerpt of the project):

- - <ItemGroup>
<MyXAPFile Include="C:\content\xact\Pong.xap" />
</ItemGroup>
<UsingTask TaskName="BuildXact" AssemblyName="Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" />
- <Target Name="Build">
<BuildXact XactProjects="@(MyXAPFile)" XnaFrameworkVersion="1.0" TargetPlatform="Windows" RebuildAll="true" OutputDirectory="c:\content\xact\Win" IntermediateDirectory="c:\content\xact\Temp" />
</Target>
</Project>
I'm using the same buildEngine.BuildProject to execute the task from within a form. At least this time I get the following output on the logger... suggestions (thanks!)

Build FAILED.

MSBUILD : error MSB4018: The "BuildXact" task failed unexpectedly.

MSBUILD : error MSB4018: System.ArgumentNullException: Value cannot be null.

MSBUILD : error MSB4018: Parameter name: path1

MSBUILD : error MSB4018: at System.IO.Path.Combine(String path1, String path2)

MSBUILD : error MSB4018: at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildXactCoordinator.GetXactBuildExecutePath()

MSBUILD : error MSB4018: at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildXactCoordinator..ctor(MSBuildLogger buildLogger, BuildCoordinatorSettings settings, String xnaFrameworkVersion)

MSBUILD : error MSB4018: at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildXact.Execute()

MSBUILD : error MSB4018: at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)

0 Warning(s)

1 Error(s)





Re: XNA Framework XAP Importer

Vasura

I finally figured out how to make the outputs work for the call to Engine.BuildProject, just in case somebody is interested, the problem was that I was taking for granted that the output for the Target was the same as the output for the Task in it.

If we want to get the output from the BuildContent we must set the 'Outputs' property on the Target too. This worked for me:

- <Target Name="Build" Outputs="@(MyFiles)">
- <BuildContent SourceAssets="@(Content)" PipelineAssemblies="@(PipelineAssembly)" TargetPlatform="Windows" OutputDirectory="bin/Temp" RebuildAll="true">
<Output TaskParameter="OutputContentFiles" ItemName="MyFiles" />
</BuildContent>
</Target>

Now, I just have to make the BuildXact work too and we'll be done here ;)





Re: XNA Framework XAP Importer

Shawn Hargreaves - MSFT

Cool!

Makes sense really - well figured out :-)





Re: XNA Framework XAP Importer

Wotan9

Vasura,

Did you manage to use BuildXact with XNA Build Because I'm running into the same error as you and I don't manage to solve the problem.





Re: XNA Framework XAP Importer

Vasura

Actually no... after reaching a certain despair level I gave up trying to make it work how I was initially planning.

What I did was to have a look at the original build projects used by XNA and I ended up making my own version upon it. I cannot access my files from this computer, but I'll have a look asap and post some details if you want.