/// <summary> /// Process the old style csproj file /// </summary> /// <param name="project"></param> /// <param name="projectItem"></param> /// <returns></returns> private ProjectVersion ProcessOldStyleProject(Project project, ProjectItem projectItem) { ThreadHelper.ThrowIfNotOnUIThread(); string version = String.Empty; string fileVersion = String.Empty; if (!projectItem.IsOpen) { projectItem.Open(); } var aDoc = projectItem.Document; TextDocument editDoc = (TextDocument)aDoc.Object("TextDocument"); var objEditPt = editDoc.StartPoint.CreateEditPoint(); objEditPt.StartOfDocument(); var endPpint = editDoc.EndPoint.CreateEditPoint(); endPpint.EndOfDocument(); string searchText = "AssemblyVersion(\""; string searchText2 = "AssemblyFileVersion(\""; var ednLine = endPpint.Line; while (objEditPt.Line <= ednLine) { var aLine = objEditPt.GetText(objEditPt.LineLength); if (!aLine.StartsWith("//") && !aLine.StartsWith("'")) { if (aLine.Contains(searchText)) { //now get the version number int locationStart = aLine.IndexOf(searchText); string remaining = aLine.Substring((locationStart + searchText.Length)); int locationEnd = remaining.IndexOf("\""); version = remaining.Substring(0, locationEnd); } if (aLine.Contains(searchText2)) { int locationStart = aLine.IndexOf(searchText2); string remaining = aLine.Substring((locationStart + searchText2.Length)); int locationEnd = remaining.IndexOf("\""); fileVersion = remaining.Substring(0, locationEnd); } } if (!String.IsNullOrWhiteSpace(version) && !String.IsNullOrWhiteSpace(fileVersion)) { break; } if (objEditPt.Line == ednLine) { break; } else { objEditPt.LineDown(); objEditPt.StartOfLine(); } } aDoc.Close(); aDoc = null; if (version != String.Empty) { var newVersion = new ProjectVersion(); newVersion.Name = project.Name; newVersion.Path = projectItem.FileNames[0]; newVersion.RealProject = project; newVersion.ProjectItem = projectItem; newVersion.ProjectType = "Standard"; try { newVersion.AssemblyVersion = new Version(version); } catch { newVersion.AssemblyVersion = new Version("1.0"); } if (fileVersion != String.Empty) { try { newVersion.FileVersion = new Version(fileVersion); } catch { newVersion.FileVersion = newVersion.AssemblyVersion; } } return(newVersion); } else { var newFailedProject = new FailedProject() { Name = project.Name, FailedAssemblyVersion = string.IsNullOrWhiteSpace(version), FailedAssemblyFileVersion = string.IsNullOrWhiteSpace(fileVersion), }; FailedProjects.Add(newFailedProject); } return(null); }
/// <summary> /// Builds the versions from the projects /// </summary> /// <param name="MainSolution">The main solution.</param> /// <returns></returns> /// <exception cref="System.Exception"></exception> public ProjectVersionCollection BuildVersions(Solution MainSolution) { ThreadHelper.ThrowIfNotOnUIThread(); var versions = new ProjectVersionCollection(); var projs = FindProjects(MainSolution); try { foreach (Project proj in projs) { if (!String.IsNullOrEmpty(proj.FileName) && proj.ProjectItems != null) { bool hasCocoa = false; bool hasAndroid = false; var projectTypeGuids = GetProjectTypeGuids(proj); ProjectItem projectItem = null; if (projectTypeGuids != null) { var ignorableTypes = new List <string>() { "{54435603-DBB4-11D2-8724-00A0C9A8B90C}" , "{930C7802-8A8C-48F9-8165-68863BCCD9DD}" , "{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}" // Sandcast Help File Builder project }; var firstTypeId = projectTypeGuids.First().ToUpper(); //if the type of the project is on the ignore list then skip if (ignorableTypes.Contains(firstTypeId)) { continue; } var iOSTypes = new List <String> { "{FEACFBD2-3405-455C-9665-78FE426C6842}", "{EE2C853D-36AF-4FDB-B1AD-8E90477E2198}" }; var androidTypes = new List <String> { "{EFBA0AD7-5A72-4C68-AF49-83D382785DCF}", "{10368E6C-D01B-4462-8E8B-01FC667A7035}" }; var macTypes = new List <String> { "{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1}", "{EE2C853D-36AF-4FDB-B1AD-8E90477E2198}" }; if (iOSTypes.Contains(projectTypeGuids.First()) || macTypes.Contains(projectTypeGuids.First())) { hasCocoa = true; } else if (androidTypes.Contains(projectTypeGuids.First())) { hasAndroid = true; } projectItem = FindAssemblyInfoProjectItem(proj.ProjectItems); if (projectItem == null) { var newFailedProject = new FailedProject() { Name = proj.Name, Reason = Enum.FailureReason.MissingAssemblyInfo, }; FailedProjects.Add(newFailedProject); continue; } } else { projectItem = FindAssemblyInfoProjectItem(proj.ProjectItems); } var newVersion = LoadVersionNumber(proj, projectItem, hasCocoa, hasAndroid); if (newVersion != null) { versions.Add(newVersion); if (hasCocoa == true) { versions.HasIosMac = true; } if (hasAndroid == true) { versions.HasAndroid = true; } } } } } catch (Exception) { throw; } return(versions); }