static void Merge(string inputFilePath, string outputFilePath) { var proj = MsBuildProject.FromFilePath(inputFilePath); var netCore = proj is NetCoreProject; foreach (var include in proj.ItemGroupIncludes) { if (proj.IsAssemblyInfo(include)) { continue; } fixInclude(proj, include); if (netCore) { proj.EnsureInclude(include); } } foreach (var rp in proj.AllReferencedProjects) { foreach (var include in rp.References) { proj.EnsureReference(include); } foreach (var include in rp.ItemGroupIncludes) { if (proj.IsReferenceInclude(include)) { continue; } if (proj.IsAssemblyInfo(include)) { continue; } var newInclude = proj.EnsureInclude(include); fixInclude(rp, newInclude); } } foreach (var rp in proj.ProjectReferences) { proj.RemoveProjectReference(rp.GetInclude()); } // various paths var icon = proj.ApplicationIcon; if (icon != null) { var text = icon.InnerText.Nullify(); if (text != null) { var path = Path.GetFullPath(Path.Combine(proj.ProjectDirectoryPath, text)); icon.InnerText = path; } } IOUtilities.EnsureFileDirectory(outputFilePath); proj.Save(outputFilePath); void fixInclude(MsBuildProject project, XmlElement includeElement) { var includePath = includeElement.GetInclude(); Console.WriteLine(includeElement.Name + ": " + includePath); var path = Path.GetFullPath(Path.Combine(project.ProjectDirectoryPath, includePath)); includeElement.SetAttribute("Include", path); } }