private static void ProcessMetaTemplate(FileInfo templateFile, FileInfo outputFile, string guid, Dictionary <string, int> executionOrderEntries = null) { if (!FileTemplate.TryParseTemplate(templateFile, out FileTemplate template)) { throw new ArgumentException($"Failed to parse template file: {templateFile?.FullName ?? "null FileInfo"}"); } TemplatedWriter writer = new TemplatedWriter(template); TemplatedWriter projectGuidWriter = writer.CreateWriterFor("PROJECT_GUID"); projectGuidWriter.Write("PROJECT_GUID", guid); if ((executionOrderEntries?.Count ?? 0) == 0) { TemplatedWriter executionOrderWriter = writer.CreateWriterFor("EXECUTION_ORDER"); executionOrderWriter.Write("EMPTY", "{}"); // By not creating a writer for the EXECUTION_ORDER_ENTRY template, we avoid adding any text for said template. } else { TemplatedWriter executionOrderWriter = writer.CreateWriterFor("EXECUTION_ORDER"); executionOrderWriter.Write("EMPTY", string.Empty); foreach (KeyValuePair <string, int> pair in executionOrderEntries) { TemplatedWriter executionOrderEntryWriter = writer.CreateWriterFor("EXECUTION_ORDER_ENTRY"); executionOrderEntryWriter.Write("SCRIPT_FULL_NAME", pair.Key); executionOrderEntryWriter.Write("SCRIPT_EXECUTION_VALUE", pair.Value.ToString()); } } writer.Export(outputFile); }
public void ExportPlatformPropsFile(CompilationPlatformInfo platform, bool inEditorConfiguration) { string configuration = inEditorConfiguration ? "InEditor" : "Player"; if (!FileTemplate.TryParseTemplate(TemplateFiles.Instance.GetTemplateFilePathForPlatform(platform.Name, configuration, platform.ScriptingBackend), out FileTemplate fileTemplate)) { throw new InvalidOperationException("Failed to parse template file for common props."); } ITemplatePart rootPart = fileTemplate.Root; TemplateReplacementSet rootReplacementSet = rootPart.CreateReplacementSet(); if (inEditorConfiguration) { ProcessPlatformTemplate(rootPart, rootReplacementSet, platform.Name, configuration, platform.BuildTarget, platform.TargetFramework, platform.CommonPlatformReferences.Concat(platform.AdditionalInEditorReferences), platform.CommonPlatformDefines.Concat(platform.AdditionalInEditorDefines)); } else { ProcessPlatformTemplate(rootPart, rootReplacementSet, platform.Name, configuration, platform.BuildTarget, platform.TargetFramework, platform.CommonPlatformReferences.Concat(platform.AdditionalPlayerReferences), platform.CommonPlatformDefines.Concat(platform.AdditionalPlayerDefines)); } fileTemplate.Write(Path.Combine(generatedOutputFolder.FullName, $"{platform.Name}.{configuration}.props"), rootReplacementSet); }
public IWSAPlayerPlatformPropsExporter CreateWSAPlayerPlatformPropsExporter(FileInfo path, ScriptingBackend scriptingBackend) { if (!FileTemplate.TryParseTemplate(TemplateFiles.Instance.GetTemplateFilePathForPlatform("WSA", "Player", scriptingBackend), out FileTemplate fileTemplate)) { throw new InvalidOperationException("Failed to parse template file for common props."); } return(new TemplatedWSAPlayerPlatformPropsExporter(fileTemplate, path)); }
public IPlatformPropsExporter CreatePlatformPropsExporter(FileInfo path, string unityConfiguration, string unityPlatform, ScriptingBackend scriptingBackend) { if (!FileTemplate.TryParseTemplate(TemplateFiles.Instance.GetTemplateFilePathForPlatform(unityPlatform, unityConfiguration, scriptingBackend), out FileTemplate fileTemplate)) { throw new InvalidOperationException("Failed to parse template file for common props."); } return(new TemplatedPlatformPropsExporter(fileTemplate, path)); }
/// <summary> /// Creates a new instance of the template driven <see cref="IProjectExporter"/>. /// </summary> /// <param name="generatedOutputFolder">The output folder for the projects and props.</param> /// <param name="solutionFileTemplatePath">The path to the solution template.</param> /// <param name="projectFileTemplatePath">The path to the C# project file template.</param> /// <param name="projectPropsFileTemplatePath">The path to the props file template.</param> /// <param name="projectTargetsFileTemplatePath">The path to the targets file template.</param> /// <param name="generatedProjectFileTemplatePath">The path to the generated project file that won't be checked-in.</param> /// <param name="msbuildForUnityCommonTemplatePath">Path to the common props file that is quick generated.</param> /// <param name="dependenciesProjectTemplatePath">Path to the dependencies project template file.</param> /// <param name="dependenciesPropsTemplatePath">Path to the dependencies props template file.</param> /// <param name="dependenciesTargetsTemplatePath">Path to the dependencies targets template file.</param> public TemplatedProjectExporter(DirectoryInfo generatedOutputFolder, FileInfo solutionFileTemplatePath, FileInfo projectFileTemplatePath, FileInfo generatedProjectFileTemplatePath, FileInfo projectPropsFileTemplatePath, FileInfo projectTargetsFileTemplatePath, FileInfo msbuildForUnityCommonTemplatePath, FileInfo dependenciesProjectTemplatePath, FileInfo dependenciesPropsTemplatePath, FileInfo dependenciesTargetsTemplatePath) { this.generatedOutputFolder = generatedOutputFolder; FileTemplate.TryParseTemplate(projectFileTemplatePath, out projectFileTemplate); FileTemplate.TryParseTemplate(generatedProjectFileTemplatePath, out generatedProjectFileTemplate); FileTemplate.TryParseTemplate(projectPropsFileTemplatePath, out propsFileTemplate); FileTemplate.TryParseTemplate(projectTargetsFileTemplatePath, out targetsFileTemplate); FileTemplate.TryParseTemplate(solutionFileTemplatePath, out solutionFileTemplate); FileTemplate.TryParseTemplate(msbuildForUnityCommonTemplatePath, out msbuildForUnityCommonTemplate); FileTemplate.TryParseTemplate(dependenciesProjectTemplatePath, out dependenciesProjectTemplate); FileTemplate.TryParseTemplate(dependenciesPropsTemplatePath, out dependenciesPropsTemplate); FileTemplate.TryParseTemplate(dependenciesTargetsTemplatePath, out dependenciesTargetsTemplate); }