public void LoadSolution(string slnFilename) { _slnFilename = slnFilename; ////read sln file _slnMx = new SolutionMx(); _slnMx.ReadSolution(slnFilename); cmbNetStd.Items.AddRange(new object[] { "classic", //"netstandard1.3", //"netstandard1.6", "netstandard2.0", //"netstandard2.1", "xamarin_ios", "xamarin_droid", "xamarin_ios_and_droid" }); cmbNetStd.SelectedIndex = 0; _slnListViewController = new SolutionListViewController(); _slnListViewController.SetSolutionListView(this.listView1); _slnListViewController.SetMergePlanListView(this.listView2); _slnListViewController.SetProjectReferenceListView(this.lstAsmReferenceList); _slnListViewController.LoadSolutionMx(_slnMx); }
public static void ConvertToLinkProjectNetStd(SolutionMx slnMx, string srcProject, string autoGenFolder, string targetFramework, bool removeOriginalSrcProject) { SimpleNetStdProj netstdProj = new SimpleNetStdProj(); netstdProj.SdkVersion = "Microsoft.NET.Sdk"; netstdProj.TargetFramework = targetFramework; //copy 'condition' nodes //------------------------------------ XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(srcProject); netstdProj.AddPropertyGroups(SelectPropertyGroups(xmldoc.DocumentElement)); List <XmlElement> compileNodes = SelectCompileNodes(xmldoc.DocumentElement); string onlyFileName = Path.GetFileName(srcProject); string saveFileName = slnMx.SolutionDir + "\\" + autoGenFolder + "\\" + onlyFileName; string targetSaveFolder = slnMx.SolutionDir + "\\" + autoGenFolder; //------------------------------------ foreach (XmlElement elem in compileNodes) { XmlAttribute includeAttr = elem.GetAttributeNode("Include"); netstdProj.AddCompileNode( slnMx.BuildPathRelativeToOther(targetSaveFolder, SolutionMx.CombineRelativePath(includeAttr.Value), out string leftPart, out string rightPart), // rightPart ); } string targetSaveDir = System.IO.Path.GetDirectoryName(saveFileName); if (!Directory.Exists(targetSaveDir)) { Directory.CreateDirectory(targetSaveDir); } //xmldoc.Save(saveFileName); netstdProj.Save(saveFileName); if (removeOriginalSrcProject) { File.Delete(srcProject); } //------------------------------------ }
private void cmdReadSln_Click(object sender, EventArgs e) { //read sln file slnMx = new SolutionMx(); slnMx.ReadSolution(@"D:\projects\HTML-Renderer\Source\MainDev.sln"); _slnListViewController = new SolutionListViewController(); _slnListViewController.SetSolutionListView(this.listView1); _slnListViewController.SetMergePlanListView(this.listView2); _slnListViewController.SetProjectReferenceListView(this.lstAsmReferenceList); _slnListViewController.LoadSolutionMx(slnMx); }
public static void ConvertToLinkProjectXamarin_droid(SolutionMx slnMx, string srcProject, string autoGenFolder, string targetFramework, bool removeOriginalSrcProject) { SimpleXamarin_MobileProj simpleXamarinProj = new SimpleXamarin_MobileProj(MobileProjPlatform.Android); XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(srcProject); XmlElement rootDoc = xmldoc.DocumentElement; List <XmlElement> compileNodes = SelectCompileNodes(xmldoc.DocumentElement); string onlyFileName = Path.GetFileName(srcProject); string onlyFilenameNoExtension = System.IO.Path.GetFileNameWithoutExtension(onlyFileName); string saveFileName = slnMx.SolutionDir + "\\" + autoGenFolder + "\\" + onlyFileName; string targetSaveFolder = slnMx.SolutionDir + "\\" + autoGenFolder; //TODO: review here, //temp fix simpleXamarinProj.RootNamespace = simpleXamarinProj.AssemblyName = onlyFilenameNoExtension + ".Droid"; //simpleXamarinProj.DefineConstants = ";PIXEL_FARM; PIXEL_FARM_NET20; NET20; MINIMAL; GLES; WIN32; GL_ENABLE; SHARPZIPLIB;NETSTANDARD;"; simpleXamarinProj.DefineConstants = ";PIXEL_FARM; PIXEL_FARM_NET20; NET20; GL_ENABLE; SHARPZIPLIB;NETSTANDARD;"; foreach (XmlElement elem in compileNodes) { XmlAttribute includeAttr = elem.GetAttributeNode("Include"); SimpleCompileNode compileNode = new SimpleCompileNode(); compileNode.Include = slnMx.BuildPathRelativeToOther(targetSaveFolder, SolutionMx.CombineRelativePath(includeAttr.Value), out string leftPart, out string rightPart); compileNode.Link = rightPart; simpleXamarinProj.AddCompileNode(compileNode); } string targetSaveDir = System.IO.Path.GetDirectoryName(saveFileName); if (!Directory.Exists(targetSaveDir)) { Directory.CreateDirectory(targetSaveDir); } simpleXamarinProj.Save(saveFileName); //--- File.Copy("AndroidManifest.xml", targetSaveFolder + "/AndroidManifest.xml", true); }
public void LoadSolution(string slnFilename) { this.slnFilename = slnFilename; ////read sln file slnMx = new SolutionMx(); slnMx.ReadSolution(slnFilename); _slnListViewController = new SolutionListViewController(); _slnListViewController.SetSolutionListView(this.listView1); _slnListViewController.SetMergePlanListView(this.listView2); _slnListViewController.SetProjectReferenceListView(this.lstAsmReferenceList); _slnListViewController.LoadSolutionMx(slnMx); }
public static void ConvertToLinkProject2(SolutionMx slnMx, string srcProject, string autoGenFolder, bool removeOriginalSrcProject) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(srcProject); var compileNodes = SelectCompileNodes(xmldoc.DocumentElement); string onlyFileName = Path.GetFileName(srcProject); string saveFileName = slnMx.SolutionDir + "\\" + autoGenFolder + "\\" + onlyFileName; string targetSaveFolder = slnMx.SolutionDir + "\\" + autoGenFolder; string rightPart; string beginAt = slnMx.BuildPathRelativeToSolution(targetSaveFolder, out rightPart); foreach (XmlElement elem in compileNodes) { XmlAttribute includeAttr = elem.GetAttributeNode("Include"); string includeValue = includeAttr.Value; string combinedPath = SolutionMx.CombineRelativePath(includeValue); string b2 = slnMx.BuildPathRelativeToOther(targetSaveFolder, combinedPath, out rightPart); //this version: //auto gen project is lower than original 1 level //so change the original src location //and create linked child node includeAttr.Value = "..\\" + beginAt + rightPart; XmlElement linkNode = xmldoc.CreateElement("Link", elem.NamespaceURI); linkNode.InnerText = rightPart; elem.AppendChild(linkNode); } string targetSaveDir = System.IO.Path.GetDirectoryName(saveFileName); if (!Directory.Exists(targetSaveDir)) { Directory.CreateDirectory(targetSaveDir); } xmldoc.Save(saveFileName); if (removeOriginalSrcProject) { File.Delete(srcProject); } }
public static void ConvertToLinkProject(SolutionMx slnMx, string srcProject, string autoGenFolder, bool removeOriginalSrcProject) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(srcProject); List <XmlElement> compileNodes = SelectCompileNodes(xmldoc.DocumentElement); string onlyFileName = Path.GetFileName(srcProject); string saveFileName = slnMx.SolutionDir + "\\" + autoGenFolder + "\\" + onlyFileName; string targetSaveFolder = slnMx.SolutionDir + "\\" + autoGenFolder; foreach (XmlElement elem in compileNodes) { XmlAttribute includeAttr = elem.GetAttributeNode("Include"); includeAttr.Value = slnMx.BuildPathRelativeToOther(targetSaveFolder, SolutionMx.CombineRelativePath(includeAttr.Value), out string leftPart, out string rightPart); XmlElement linkNode = xmldoc.CreateElement("Link", elem.NamespaceURI); linkNode.InnerText = rightPart; elem.AppendChild(linkNode); } string targetSaveDir = System.IO.Path.GetDirectoryName(saveFileName); if (!Directory.Exists(targetSaveDir)) { Directory.CreateDirectory(targetSaveDir); } xmldoc.Save(saveFileName); if (removeOriginalSrcProject) { File.Delete(srcProject); } }
public void MergeAndSave(string csprojFilename, string assemblyName, string targetFrameworkVersion, string additonalDefineConst, string[] references) { ProjectRootElement root = ProjectRootElement.Create(); if (portable) { root.ToolsVersion = "14.0"; root.DefaultTargets = "Build"; var import = root.AddImport(@"$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"); import.Condition = @"Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"; } else { root.AddImport(@"$(MSBuildToolsPath)\Microsoft.CSharp.targets"); } ProjectPropertyGroupElement one1 = CreatePropertyGroup(root, targetFrameworkVersion, " '$(Configuration)' == '' ", " '$(Platform)' == '' ", "Debug", "AnyCPU", true, assemblyName); if (portable) { one1.AddProperty("MinimumVisualStudioVersion", "10.0"); one1.AddProperty("ProjectTypeGuids", "{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"); one1.AddProperty("TargetFrameworkProfile", "Profile111"); } ProjectPropertyGroupElement debugGroup = CreatePropertyGroupChoice(root, " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ", true, @"bin\Debug\", false, true, "full", "DEBUG; TRACE" + additonalDefineConst); ProjectPropertyGroupElement releaseGroup = CreatePropertyGroupChoice(root, " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ", true, @"bin\Release\", true, false, "pdbonly", " TRACE" + additonalDefineConst); if (references.Length > 0) { AddItems(root, "Reference", references); } List <string> allList = new List <string>(); Dictionary <string, bool> uniqueFileList = new Dictionary <string, bool>(); string onlyProjPath = Path.GetDirectoryName(csprojFilename) + "\\"; int onlyProjPathLength = onlyProjPath.Length; //TODO: review here //special for support .net20 bool foundFirstExtensionAttributeFile = false; foreach (ToMergeProject toMergePro in subProjects) { List <string> allAbsFiles = toMergePro.GetAllAbsoluteFilenames(); foreach (string filename in allAbsFiles) { string onlyFileName = Path.GetFileName(filename); if (onlyFileName == "PORTING_NOTMERGE.cs") { //our convention continue;//skip } else if (onlyFileName == "ExtensionAttribute.cs") { //this is our convention //... if we have ExtensionAttribute.cs //the if (foundFirstExtensionAttributeFile) { continue; } else { foundFirstExtensionAttributeFile = true; } } string combindedFilename = SolutionMx.CombineRelativePath(filename).ToUpper(); if (uniqueFileList.ContainsKey(combindedFilename)) { continue; } uniqueFileList[combindedFilename] = true;// if (filename.StartsWith(onlyProjPath)) { allList.Add(filename.Substring(onlyProjPathLength)); } else { allList.Add(filename); } } } // items to compile AddItems(root, "Compile", allList.ToArray()); if (portable) { root.AddImport(@"$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets"); } root.Save(csprojFilename); }
public void LoadSolutionMx(SolutionMx solutionMx) { _solutionMx = solutionMx; _listview.SuspendLayout(); _listview.Controls.Clear(); mergePlansProjects.Clear(); List <SolutionProject> tmpProjects = new List <SolutionProject>(); foreach (SolutionProject project in solutionMx._currentSolution.Projects) { if (project.RelativePath.Contains("x_merge_projects")) { //BY CONVENTION: //this is special 'merge plan' project mergePlansProjects.Add(project); } else { tmpProjects.Add(project); } } //------- //sort tmpProjects.Sort((p0, p1) => p0.ProjectName.CompareTo(p1.ProjectName)); mergePlansProjects.Sort((p0, p1) => p0.ProjectName.CompareTo(p1.ProjectName)); // //------- foreach (SolutionProject project in tmpProjects) { ListViewItem lstItem = new ListViewItem(); switch (project.ProjectType) { case "KnownToBeMSBuildFormat": //project lstItem.Text = project.ProjectName; lstItem.Tag = project; _listview.Items.Add(lstItem); break; case "SolutionFolder": //skip solution folder break; default: break; } } _listview.ResumeLayout(); //------- _mergePlanListView.Items.Clear(); _mergePlanListView.SuspendLayout(); foreach (SolutionProject project in mergePlansProjects) { ListViewItem lstItem = new ListViewItem(); switch (project.ProjectType) { case "KnownToBeMSBuildFormat": //project lstItem.Text = project.ProjectName; lstItem.Tag = project; _mergePlanListView.Items.Add(lstItem); break; case "SolutionFolder": //skip solution folder break; default: break; } } _mergePlanListView.ResumeLayout(); }