in Assets/MRTK/Tools/MSBuild/Scripts/AssetScriptReferenceRetargeter.cs [671:813]
private static void UpdateMetaFiles(Dictionary<string, AssemblyInformation> assemblyInformation)
{
if (!TemplateFiles.Instance.PluginMetaTemplatePaths.TryGetValue(BuildTargetGroup.Unknown, out FileInfo editorMetaFile))
{
throw new FileNotFoundException("Could not find sample editor dll.meta template.");
}
if (!TemplateFiles.Instance.PluginMetaTemplatePaths.TryGetValue(BuildTargetGroup.WSA, out FileInfo uwpMetaFile))
{
throw new FileNotFoundException("Could not find sample UWP dll.meta template.");
}
if (!TemplateFiles.Instance.PluginMetaTemplatePaths.TryGetValue(BuildTargetGroup.Standalone, out FileInfo standaloneMetaFile))
{
throw new FileNotFoundException("Could not find sample standalone dll.meta template.");
}
if (!TemplateFiles.Instance.PluginMetaTemplatePaths.TryGetValue(BuildTargetGroup.Android, out FileInfo androidMetaFile))
{
throw new FileNotFoundException("Could not find sample Android dll.meta template.");
}
if (!TemplateFiles.Instance.PluginMetaTemplatePaths.TryGetValue(BuildTargetGroup.iOS, out FileInfo iOSMetaFile))
{
throw new FileNotFoundException("Could not find sample iOS dll.meta template.");
}
string editorMetaFileTemplate = File.ReadAllText(editorMetaFile.FullName);
string uapMetaFileTemplate = File.ReadAllText(uwpMetaFile.FullName);
string standaloneMetaFileTemplate = File.ReadAllText(standaloneMetaFile.FullName);
string androidMetaFileTemplate = File.ReadAllText(androidMetaFile.FullName);
string iOSMetaFileTemplate = File.ReadAllText(iOSMetaFile.FullName);
Dictionary<AssemblyInformation, FileInfo[]> mappings = new DirectoryInfo(Application.dataPath.Replace("Assets", "NuGet/Plugins"))
.GetDirectories("*", SearchOption.AllDirectories)
.SelectMany(t => t.EnumerateFiles().Where(f => f.FullName.EndsWith(".dll") || f.FullName.EndsWith(".pdb")))
.GroupBy(t => Path.GetFileNameWithoutExtension(t.Name))
.ToDictionary(t => assemblyInformation[t.Key], t => t.ToArray());
foreach (KeyValuePair<AssemblyInformation, FileInfo[]> mapping in mappings)
{
// Editor is GUID + 1; which has done when we processed Editor DLLs
// Standalone is GUID + 2
// UAP is GUID + 3
// Editor PDB is + 4
// Standalone PDB is + 5
// UAP PDB is + 6
// Android is GUID + 7
// iOS is GUID + 8
// Android PDB is + 9
// iOS PDB is + 10
string templateToUse = editorMetaFileTemplate;
foreach (FileInfo file in mapping.Value)
{
string dllGuid = mapping.Key.Guid;
// First cycle happens in RetrieveAsmDefGuids
// dllGuid = CycleGuidForward(dllGuid);
if (file.Extension.Equals(".dll") && file.DirectoryName.EndsWith("EditorPlayer"))
{
templateToUse = editorMetaFileTemplate;
goto WriteMeta;
}
dllGuid = CycleGuidForward(dllGuid);
if (file.Extension.Equals(".dll") && file.DirectoryName.EndsWith("StandalonePlayer"))
{
templateToUse = standaloneMetaFileTemplate;
goto WriteMeta;
}
dllGuid = CycleGuidForward(dllGuid);
if (file.Extension.Equals(".dll") && file.DirectoryName.EndsWith("UAPPlayer"))
{
templateToUse = uapMetaFileTemplate;
goto WriteMeta;
}
dllGuid = CycleGuidForward(dllGuid);
// Switch to PDBs
if (file.Extension.Equals(".pdb") && file.DirectoryName.EndsWith("EditorPlayer"))
{
templateToUse = editorMetaFileTemplate;
goto WriteMeta;
}
dllGuid = CycleGuidForward(dllGuid);
if (file.Extension.Equals(".pdb") && file.DirectoryName.EndsWith("StandalonePlayer"))
{
templateToUse = standaloneMetaFileTemplate;
goto WriteMeta;
}
dllGuid = CycleGuidForward(dllGuid);
if (file.Extension.Equals(".pdb") && file.DirectoryName.EndsWith("UAPPlayer"))
{
templateToUse = uapMetaFileTemplate;
goto WriteMeta;
}
dllGuid = CycleGuidForward(dllGuid);
if (file.Extension.Equals(".dll") && file.DirectoryName.EndsWith("AndroidPlayer"))
{
templateToUse = androidMetaFileTemplate;
goto WriteMeta;
}
dllGuid = CycleGuidForward(dllGuid);
if (file.Extension.Equals(".dll") && file.DirectoryName.EndsWith("iOSPlayer"))
{
templateToUse = iOSMetaFileTemplate;
goto WriteMeta;
}
dllGuid = CycleGuidForward(dllGuid);
if (file.Extension.Equals(".pdb") && file.DirectoryName.EndsWith("AndroidPlayer"))
{
templateToUse = androidMetaFileTemplate;
goto WriteMeta;
}
dllGuid = CycleGuidForward(dllGuid);
if (file.Extension.Equals(".pdb") && file.DirectoryName.EndsWith("iOSPlayer"))
{
templateToUse = iOSMetaFileTemplate;
goto WriteMeta;
}
WriteMeta:
string metaFilePath = $"{file.FullName}.meta";
File.WriteAllText(metaFilePath, ProcessMetaTemplate(templateToUse, dllGuid, mapping.Key.ExecutionOrderEntries));
}
}
}