Skip to content
Browse files

Merge pull request #1664 from SickheadGames/mgcb

MGCB Support For Content Projects
  • Loading branch information...
2 parents db964fe + dce1911 commit e44a101d299d6b4495afd42e6614bc29b3b2c5d8 @KonajuGames KonajuGames committed Apr 23, 2013
View
101 MonoGame.Framework.Content.Pipeline/MonoGame.Content.Pipeline.targets
@@ -0,0 +1,101 @@
+<!--
+ MonoGame - Copyright (C) The MonoGame Team
+ This file is subject to the terms and conditions defined in
+ file 'LICENSE.txt', which is part of this source code package.
+-->
+
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <UsingTask TaskName="MonoGame_ParseContent" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
+ <ParameterGroup>
+ <Items ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
+ <Result ParameterType="System.String" Output="true" />
+ </ParameterGroup>
+ <Task>
+ <Code Type="Fragment" Language="cs"><![CDATA[
+
+ foreach (var item in Items)
+ {
+ Result += string.Format("\r\n/importer:{0}\r\n", item.GetMetadata("Importer"));
+ Result += string.Format("/processor:{0}\r\n", item.GetMetadata("Processor"));
+
+ foreach (string meta in item.MetadataNames)
+ {
+ if (meta.StartsWith("ProcessorParameters_"))
+ Result += string.Format("/processorParam:{0}={1}\r\n", meta.Substring(20), item.GetMetadata(meta));
+ }
+
+ Result += string.Format("/build:{0}\r\n", item.ItemSpec);
+ }
+
+ ]]></Code>
+ </Task>
+ </UsingTask>
+
+ <PropertyGroup>
+
+ <!-- Make sure some default properties are setup properly -->
+ <Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
+ <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
+ <OutputPath Condition="'$(OutputPath)' == ''">bin\$(Platform)\$(Configuration)</OutputPath>
+ <IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">obj\$(Platform)\$(Configuration)</IntermediateOutputPath>
+
+ <ContentResponseFile>$(IntermediateOutputPath)\mgcontent.txt</ContentResponseFile>
+ <MonoGameContentBuilderExe>$(MSBuildExtensionsPath)\MonoGame\v3.0\MGCB.exe</MonoGameContentBuilderExe>
+ <MonoGamePlatform Condition="'$(MonoGamePlatform)' == ''">Windows</MonoGamePlatform>
+
+ <AssemblySearchPaths>
+ {CandidateAssemblyFiles};
+ $(ReferencePath);
+ {HintPathFromItem};
+ {TargetFrameworkDirectory};
+ {AssemblyFolders};
+ {GAC};
+ {RawFileName};
+ $(OutputPath);
+ </AssemblySearchPaths>
+
+ </PropertyGroup>
+
+ <Target Name="MonoGame_WriteResponseFile">
+
+ <MakeDir Directories="$(IntermediateOutputPath)"/>
+ <MakeDir Directories="$(OutputPath)"/>
+
+ <WriteLinesToFile File="$(ContentResponseFile)" Lines="/outputDir:$(OutputPath)\$(ContentRootDirectory)" Overwrite="true"/>
+ <WriteLinesToFile File="$(ContentResponseFile)" Lines="/intermediateDir:$(IntermediateOutputPath)\$(ContentRootDirectory)"/>
+ <WriteLinesToFile File="$(ContentResponseFile)" Lines="/config:$(Configuration)"/>
+ <WriteLinesToFile File="$(ContentResponseFile)" Lines="/platform:$(MonoGamePlatform)"/>
+
+ <ResolveAssemblyReference Assemblies="@(Reference)" SearchPaths="$(AssemblySearchPaths)" Silent="true">
+ <Output ItemName="ResolvedReferences" TaskParameter="ResolvedFiles"/>
+ </ResolveAssemblyReference>
+
+ <WriteLinesToFile File="$(ContentResponseFile)" Lines="@(ResolvedReferences->'/reference:%(FullPath)')"/>
+
+ </Target>
+
+ <Target Name="MonoGame_WriteContent" DependsOnTargets="MonoGame_WriteResponseFile">
+
+ <MonoGame_ParseContent Items="@(Compile)">
+ <Output ItemName="ContentItems" TaskParameter="Result" />
+ </MonoGame_ParseContent>
+
+ <WriteLinesToFile File="$(ContentResponseFile)" Lines="@(ContentItems)"/>
+
+ </Target>
+
+ <Target Name="Build" DependsOnTargets="MonoGame_WriteContent">
+ <Exec Command="$(MonoGameContentBuilderExe) /@:$(ContentResponseFile) /quiet" EchoOff="true"/>
+ </Target>
+
+ <Target Name="Rebuild" DependsOnTargets="MonoGame_WriteContent">
+ <Exec Command="$(MonoGameContentBuilderExe) /@:$(ContentResponseFile) /quiet /rebuild" EchoOff="true"/>
+ </Target>
+
+ <Target Name="Clean" DependsOnTargets="MonoGame_WriteResponseFile">
+ <Exec Command="$(MonoGameContentBuilderExe) /@:$(ContentResponseFile) /quiet /clean" EchoOff="true"/>
+ <Delete Files="$(ContentResponseFile)"/>
+ </Target>
+
+</Project>
View
8 Tools/MGCB/BuildContent.cs
@@ -15,6 +15,11 @@ namespace MGCB
class BuildContent
{
[CommandLineParameter(
+ Name = "quiet",
+ Description = "Only output content build errors.")]
+ public bool Quiet;
+
+ [CommandLineParameter(
Name = "@",
ValueName = "responseFile",
Description = "Read a text response file with additional command line options and switches.")]
@@ -220,7 +225,8 @@ public void Build(out int successCount, out int errorCount)
// Delete the old file and write the new content
// list if we have any to serialize.
- File.Delete(contentFile);
+ if (File.Exists(contentFile))
+ File.Delete(contentFile);
if (newContent.SourceFiles.Count > 0)
newContent.Write(contentFile);
}
View
13 Tools/MGCB/Program.cs
@@ -5,7 +5,6 @@
using System;
using System.IO;
using System.Linq;
-using System.Reflection;
using System.Runtime.InteropServices;
namespace MGCB
@@ -60,17 +59,21 @@ static int Main(string[] args)
return 0;
}
- // Print a startup message.
+ // Print a startup message.
var buildStarted = DateTime.Now;
- Console.WriteLine("Build started {0}\n", buildStarted);
+ if (!content.Quiet)
+ Console.WriteLine("Build started {0}\n", buildStarted);
// Let the content build.
int successCount, errorCount;
content.Build(out successCount, out errorCount);
// Print the finishing info.
- Console.WriteLine("\nBuild {0} succeeded, {1} failed.\n", successCount, errorCount);
- Console.WriteLine("Time elapsed {0:hh\\:mm\\:ss\\.ff}.", DateTime.Now - buildStarted);
+ if (!content.Quiet)
+ {
+ Console.WriteLine("\nBuild {0} succeeded, {1} failed.\n", successCount, errorCount);
+ Console.WriteLine("Time elapsed {0:hh\\:mm\\:ss\\.ff}.", DateTime.Now - buildStarted);
+ }
// Return the error count.
return errorCount;

0 comments on commit e44a101

Please sign in to comment.
Something went wrong with that request. Please try again.