public void MsSlnToCmbxHelper(string slnFileName) { int i = 0; FileStream fsOut = null; XmlSerializer xmlSer = null; //StringBuilder MakefileBuilder = new StringBuilder(); MonoDevelop.Prj2Make.Schema.Cmbx.Combine cmbxObj = new MonoDevelop.Prj2Make.Schema.Cmbx.Combine(); cmbxFileName = String.Format ("{0}.cmbx", Path.Combine(Path.GetDirectoryName(slnFileName), Path.GetFileNameWithoutExtension(slnFileName)) ); Console.WriteLine(String.Format("Will create combine filename:{0}", cmbxFileName)); string origDir = Directory.GetCurrentDirectory(); try { string d = Path.GetDirectoryName(slnFileName); if (d != "") Directory.SetCurrentDirectory(d); // We invoke the ParseSolution // by passing the file obtained ParseSolution (slnFileName); // Create all of the prjx files form the csproj files foreach (CsprojInfo pi in projNameInfo.Values) { CreatePrjxFromCsproj(pi.csprojpath); } // Begin prjxObj population cmbxObj.name = Path.GetFileNameWithoutExtension(slnFileName); cmbxObj.description = ""; cmbxObj.fileversion = (decimal)1.0; // Create and attach the StartMode element MonoDevelop.Prj2Make.Schema.Cmbx.StartMode startModeElem = new MonoDevelop.Prj2Make.Schema.Cmbx.StartMode(); // Create the array of Execute objects MonoDevelop.Prj2Make.Schema.Cmbx.Execute[] executeElem = new MonoDevelop.Prj2Make.Schema.Cmbx.Execute[projNameInfo.Count]; // Populate the Element objects instances i = 0; foreach (CsprojInfo pi in projNameInfo.Values) { MonoDevelop.Prj2Make.Schema.Cmbx.Execute execElem = new MonoDevelop.Prj2Make.Schema.Cmbx.Execute(); execElem.entry = pi.name; execElem.type = "None"; executeElem[i++] = execElem; } startModeElem.startupentry = executeElem[0].entry; startModeElem.single = "True"; startModeElem.Execute = executeElem; // Attach the StartMode Object to the // Combine object cmbxObj.StartMode = startModeElem; // Gnerate the entries array MonoDevelop.Prj2Make.Schema.Cmbx.Entry[] entriesObj = new MonoDevelop.Prj2Make.Schema.Cmbx.Entry[projNameInfo.Count]; // Populate the Entry objects instances i = 0; foreach (CsprojInfo pi in projNameInfo.Values) { MonoDevelop.Prj2Make.Schema.Cmbx.Entry entryObj = new MonoDevelop.Prj2Make.Schema.Cmbx.Entry(); string PrjxFileName = String.Format (".{0}{1}.prjx", Path.DirectorySeparatorChar, Path.Combine(Path.GetDirectoryName(pi.csprojpath), Path.GetFileNameWithoutExtension(pi.csprojpath)) ); entryObj.filename = PrjxFileName; entriesObj[i++] = entryObj; } // Attach the Entries Object to the // Combine object cmbxObj.Entries = entriesObj; MonoDevelop.Prj2Make.Schema.Cmbx.Configurations configurationsObj = new MonoDevelop.Prj2Make.Schema.Cmbx.Configurations(); // Hack hardcoded configuration value must get the one // from analyzing the different configuration entries configurationsObj.active = "Debug"; // Hack hardcoded number of configuration object // assuming 2 for Debug and Release configurationsObj.Configuration = new MonoDevelop.Prj2Make.Schema.Cmbx.Configuration[2]; MonoDevelop.Prj2Make.Schema.Cmbx.Configuration confObj1 = new MonoDevelop.Prj2Make.Schema.Cmbx.Configuration(); configurationsObj.Configuration[0] = confObj1; MonoDevelop.Prj2Make.Schema.Cmbx.Configuration confObj2 = new MonoDevelop.Prj2Make.Schema.Cmbx.Configuration(); configurationsObj.Configuration[1] = confObj2; configurationsObj.Configuration[0].name = "Release"; configurationsObj.Configuration[0].Entry = CreateArrayOfConfEntries(); configurationsObj.Configuration[1].name = "Debug"; configurationsObj.Configuration[1].Entry = CreateArrayOfConfEntries(); // Attach the Configurations object to the // Combine Object cmbxObj.Configurations = configurationsObj; // Serialize fsOut = new FileStream (cmbxFileName, FileMode.Create); xmlSer = new XmlSerializer (typeof(MonoDevelop.Prj2Make.Schema.Cmbx.Combine)); xmlSer.Serialize(fsOut, cmbxObj); fsOut.Close(); return; } catch (Exception e) { Console.WriteLine("EXCEPTION: {0}\n", e); return; } finally { Directory.SetCurrentDirectory(origDir); } }
protected void ParseCombine(string fname) { string CombineFilePath = fname; // convert backslashes to slashes CombineFilePath = CombineFilePath.Replace("\\", "/"); // loads the file in order to deserialize and // build the object graph try { m_cmbObject = LoadCmbFromFile (CombineFilePath); } catch (Exception exc) { Console.WriteLine ( String.Format ("Could not load the file {0}\nException: {1}", CombineFilePath, exc.Message) ); return; } foreach(MonoDevelop.Prj2Make.Schema.Cmbx.Entry ent in m_cmbObject.Entries) { string projectName = System.IO.Path.GetFileNameWithoutExtension(ent.filename); string csprojPath = ent.filename; if (csprojPath.EndsWith(".prjx")) { PrjxInfo pi = new PrjxInfo(m_bIsUnix, m_bIsMcs, csprojPath); projNameInfo[projectName] = pi; } } }