private void MergeAndGenerateXaml(MergedDictionary mergedDictionary, List <string> files, string targetOSVersion, int apiVersion) { Log.LogMessage("Merge and generate xaml Files for target os" + targetOSVersion); foreach (string file in files) { try { mergedDictionary.MergeContent(File.ReadAllText(file)); } catch (Exception) { Log.LogError("Exception found when merge file " + file); throw; } } string content = mergedDictionary.ToString(); string name = targetOSVersion + "_" + PostfixForGeneratedFile + ".xaml"; string fullPath = Path.Combine(OutputDirectory, name); string prefixedName = targetOSVersion + "_" + postfixForPrefixedGeneratedFile + ".xaml"; string prefixedFullPath = Path.Combine(OutputDirectory, prefixedName); string strippedContent = StripNamespaces.StripNamespaceForAPIVersion(content, apiVersion); filesWritten.Add(Utils.RewriteFileIfNecessary(prefixedFullPath, content)); filesWritten.Add(Utils.RewriteFileIfNecessary(fullPath, strippedContent)); nextBaseFile = prefixedFullPath; }
public override bool Execute() { if (string.IsNullOrEmpty(ForOSVersion) || !StripNamespaces.universalApiContractVersionMapping.ContainsKey(ForOSVersion)) { Log.LogError("Unknown OS version, and valid version is ", string.Join(",", StripNamespaces.universalApiContractVersionMapping.Keys)); } MergedDictionary mergedDictionary = MergedDictionary.CreateMergedDicionary(); foreach (ITaskItem item in Sources) { string file = item.ItemSpec; if (File.Exists(file)) { mergedDictionary.MergeContent(File.ReadAllText(file)); } else { Log.LogError("Error to look for file " + item.ItemSpec); } } int apiVersion = StripNamespaces.universalApiContractVersionMapping[ForOSVersion]; string content = mergedDictionary.ToString(); string prefixedName = XamlFileGenerated.Substring(0, XamlFileGenerated.Length - 5) + ".prefixed.xaml"; string strippedContent = StripNamespaces.StripNamespaceForAPIVersion(content, apiVersion); string[] filesWritten = new string[2]; filesWritten[0] = Utils.RewriteFileIfNecessary(prefixedName, content); filesWritten[1] = Utils.RewriteFileIfNecessary(XamlFileGenerated, strippedContent); FilesWritten = filesWritten; return(!Log.HasLoggedErrors); }