private static ProjectItem FindProjectItem(ProjectItems projectItems, string name) { ProjectItem result; if (projectItems == null) { result = null; } else { foreach (ProjectItem projectItem in projectItems) { if (string.Compare(projectItem.Name, name, true) == 0) { result = projectItem; return(result); } if (projectItem.ProjectItems != null && projectItem.ProjectItems.Count > 0) { ProjectItem projectItem2 = SolutionItem.FindProjectItem(projectItem.ProjectItems, name); if (projectItem2 != null) { result = projectItem2; return(result); } } } result = null; } return(result); }
private static void PrepareSolutionItem(SolutionItem solutionItem) { if (solutionItem.ProjectType != LanguageType.None) { return; } var extension = Path.GetExtension(solutionItem.Filename); switch (extension) { case ".vbproj": solutionItem.ProjectType = LanguageType.VisualBasic; break; case ".vcproj": case ".vcxproj": solutionItem.ProjectType = LanguageType.CppManaged; break; case ".csproj": solutionItem.ProjectType = LanguageType.CSharp; break; } var assemblyInfo = solutionItem.FindProjectItem("AssemblyInfo.cpp"); if (assemblyInfo != null) { return; } if (extension == ".vcproj" || extension == ".vcxproj") { solutionItem.ProjectType = LanguageType.CppUnmanaged; } }
/// <summary> /// Because some part of the code must have the ability to react /// on language type this method should prepare used items /// as soon as it it possible to make it available /// </summary> private void PrepareSolutionItem(SolutionItem solutionItem) { // Do not update if there's already one if (solutionItem.ProjectType != LanguageType.None) { return; } string extension = Path.GetExtension(solutionItem.Filename); switch (extension) { case ".vbproj": solutionItem.ProjectType = LanguageType.VisualBasic; break; case ".vcproj": case ".vcxproj": solutionItem.ProjectType = LanguageType.CPPManaged; break; case ".csproj": solutionItem.ProjectType = LanguageType.CSharp; break; } ProjectItem assemblyInfo = solutionItem.FindProjectItem("AssemblyInfo.cpp"); if (assemblyInfo == null) { // we couldn't locate the file, but, if it is a C-Project, is also could be an unmanaged project if (extension == ".vcproj" || extension == ".vcxproj") { solutionItem.ProjectType = LanguageType.CPPUnmanaged; } } }
public ProjectItem FindProjectItem(string name) { ProjectItem result = null; if (this.ItemType == SolutionItemType.Project) { result = SolutionItem.FindProjectItem(this.Project.ProjectItems, name); } return(result); }
private void PrepareSolutionItem(SolutionItem solutionItem) { if (solutionItem.ProjectType == LanguageType.None) { string extension = Path.GetExtension(solutionItem.Filename); string text = extension; if (text != null) { if (!(text == ".vbproj")) { if (!(text == ".vcproj") && !(text == ".vcxproj")) { if (text == ".csproj") { solutionItem.ProjectType = LanguageType.CSharp; } } else { solutionItem.ProjectType = LanguageType.CPPManaged; } } else { solutionItem.ProjectType = LanguageType.VisualBasic; } } ProjectItem projectItem = solutionItem.FindProjectItem("AssemblyInfo.cpp"); if (projectItem == null) { if (extension == ".vcproj" || extension == ".vcxproj") { solutionItem.ProjectType = LanguageType.CPPUnmanaged; } } } }
private string GetAssemblyInfoFilename(SolutionItem solutionItem) { var filename = "AssemblyInfo"; var ext = Path.GetExtension(solutionItem.Filename); solutionItem.ProjectType = LanguageType.None; switch (ext) { case ".vbproj": filename += ".vb"; solutionItem.ProjectType = LanguageType.VisualBasic; break; case ".vcproj": case ".vcxproj": filename += ".cpp"; solutionItem.ProjectType = LanguageType.CppManaged; break; case ".csproj": filename += ".cs"; solutionItem.ProjectType = LanguageType.CSharp; break; case ".sln": if (string.IsNullOrEmpty(solutionItem.IncrementSettings.AssemblyInfoFilename)) { Logger.Write( "Can't update build version for a solution without specifying an assembly info file.", LogLevel.Error); return(null); } solutionItem.ProjectType = GetLanguageType(solutionItem.IncrementSettings.AssemblyInfoFilename); if (solutionItem.ProjectType == LanguageType.None) { Logger.Write( "Can't infer solution's assembly info file language. Please add extension to filename.", LogLevel.Error); } break; default: Logger.Write("Unknown project file type: \"" + ext + "\"", LogLevel.Error); return(null); } if (!string.IsNullOrEmpty(solutionItem.IncrementSettings.AssemblyInfoFilename)) { var basePath = Path.GetDirectoryName(solutionItem.Filename); return(Common.MakeAbsolutePath(basePath, solutionItem.IncrementSettings.AssemblyInfoFilename)); } var assemblyInfo = solutionItem.FindProjectItem(filename); if (assemblyInfo == null) { if (ext == ".vcproj" || ext == ".vcxproj") { filename = solutionItem.Name + ".rc"; assemblyInfo = solutionItem.FindProjectItem(filename); solutionItem.ProjectType = LanguageType.CppUnmanaged; } if (assemblyInfo == null) { Logger.Write($"Could not locate \"{filename}\" in project.", LogLevel.Warn); return(null); } } var ret = assemblyInfo.FileNames[0]; if (string.IsNullOrEmpty(ret)) { Logger.Write($"Located \"{filename}\" project item but failed to get filename.", LogLevel.Error); return(null); } Logger.Write($"Found \"{ret}\"", LogLevel.Debug); return(ret); }
private string GetAssemblyInfoFilename(SolutionItem solutionItem) { string text = "AssemblyInfo"; string extension = Path.GetExtension(solutionItem.Filename); solutionItem.ProjectType = LanguageType.None; string text2 = extension; string result; if (text2 != null) { if (!(text2 == ".vbproj")) { if (!(text2 == ".vcproj") && !(text2 == ".vcxproj")) { if (!(text2 == ".csproj")) { if (!(text2 == ".sln")) { goto IL_12F; } if (string.IsNullOrEmpty(solutionItem.IncrementSettings.AssemblyInfoFilename)) { Logger.Write("Can't update build version for a solution without specifying an assembly info file.", LogLevel.Error, solutionItem.Filename, 1); result = null; return(result); } solutionItem.ProjectType = this.GetLanguageType(solutionItem.IncrementSettings.AssemblyInfoFilename); if (solutionItem.ProjectType == LanguageType.None) { Logger.Write("Can't infer solution's assembly info file language. Please add extension to filename.", LogLevel.Error, solutionItem.Filename, 1); } } else { text += ".cs"; solutionItem.ProjectType = LanguageType.CSharp; } } else { text += ".cpp"; solutionItem.ProjectType = LanguageType.CPPManaged; } } else { text += ".vb"; solutionItem.ProjectType = LanguageType.VisualBasic; } if (!string.IsNullOrEmpty(solutionItem.IncrementSettings.AssemblyInfoFilename)) { string directoryName = Path.GetDirectoryName(solutionItem.Filename); result = Common.MakeAbsolutePath(directoryName, solutionItem.IncrementSettings.AssemblyInfoFilename); return(result); } ProjectItem projectItem = solutionItem.FindProjectItem(text); if (projectItem == null) { if (extension == ".vcproj" || extension == ".vcxproj") { text = solutionItem.Name + ".rc"; projectItem = solutionItem.FindProjectItem(text); solutionItem.ProjectType = LanguageType.CPPUnmanaged; } if (projectItem == null) { Logger.Write("Could not locate \"" + text + "\" in project.", LogLevel.Warning); result = null; return(result); } } string text3 = projectItem.get_FileNames(0); if (string.IsNullOrEmpty(text3)) { Logger.Write("Located \"" + text + "\" project item but failed to get filename.", LogLevel.Error); result = null; return(result); } Logger.Write("Found \"" + text3 + "\"", LogLevel.Debug); result = text3; return(result); } IL_12F: Logger.Write("Unknown project file type: \"" + extension + "\"", LogLevel.Error, solutionItem.Filename, 1); result = null; return(result); }
private void PrepareSolutionItem(SolutionItem solutionItem) { if (solutionItem.ProjectType == LanguageType.None) { string extension = Path.GetExtension(solutionItem.Filename); string text = extension; if (text != null) { if (!(text == ".vbproj")) { if (!(text == ".vcproj") && !(text == ".vcxproj")) { if (text == ".csproj") { solutionItem.ProjectType = LanguageType.CSharp; } } else { solutionItem.ProjectType = LanguageType.CPPManaged; } } else { solutionItem.ProjectType = LanguageType.VisualBasic; } } ProjectItem projectItem = solutionItem.FindProjectItem("AssemblyInfo.cpp"); if (projectItem == null) { if (extension == ".vcproj" || extension == ".vcxproj") { solutionItem.ProjectType = LanguageType.CPPUnmanaged; } } } }
private string GetAssemblyInfoFilename(SolutionItem solutionItem) { string text = "AssemblyInfo"; string extension = Path.GetExtension(solutionItem.Filename); solutionItem.ProjectType = LanguageType.None; string text2 = extension; string result; if (text2 != null) { if (!(text2 == ".vbproj")) { if (!(text2 == ".vcproj") && !(text2 == ".vcxproj")) { if (!(text2 == ".csproj")) { if (!(text2 == ".sln")) { goto IL_12F; } if (string.IsNullOrEmpty(solutionItem.IncrementSettings.AssemblyInfoFilename)) { Logger.Write("Can't update build version for a solution without specifying an assembly info file.", LogLevel.Error, solutionItem.Filename, 1); result = null; return result; } solutionItem.ProjectType = this.GetLanguageType(solutionItem.IncrementSettings.AssemblyInfoFilename); if (solutionItem.ProjectType == LanguageType.None) { Logger.Write("Can't infer solution's assembly info file language. Please add extension to filename.", LogLevel.Error, solutionItem.Filename, 1); } } else { text += ".cs"; solutionItem.ProjectType = LanguageType.CSharp; } } else { text += ".cpp"; solutionItem.ProjectType = LanguageType.CPPManaged; } } else { text += ".vb"; solutionItem.ProjectType = LanguageType.VisualBasic; } if (!string.IsNullOrEmpty(solutionItem.IncrementSettings.AssemblyInfoFilename)) { string directoryName = Path.GetDirectoryName(solutionItem.Filename); result = Common.MakeAbsolutePath(directoryName, solutionItem.IncrementSettings.AssemblyInfoFilename); return result; } ProjectItem projectItem = solutionItem.FindProjectItem(text); if (projectItem == null) { if (extension == ".vcproj" || extension == ".vcxproj") { text = solutionItem.Name + ".rc"; projectItem = solutionItem.FindProjectItem(text); solutionItem.ProjectType = LanguageType.CPPUnmanaged; } if (projectItem == null) { Logger.Write("Could not locate \"" + text + "\" in project.", LogLevel.Warning); result = null; return result; } } string text3 = projectItem.get_FileNames(0); if (string.IsNullOrEmpty(text3)) { Logger.Write("Located \"" + text + "\" project item but failed to get filename.", LogLevel.Error); result = null; return result; } Logger.Write("Found \"" + text3 + "\"", LogLevel.Debug); result = text3; return result; } IL_12F: Logger.Write("Unknown project file type: \"" + extension + "\"", LogLevel.Error, solutionItem.Filename, 1); result = null; return result; }
private string GetAssemblyInfoFilename(SolutionItem solutionItem) { if (!string.IsNullOrEmpty(solutionItem.IncrementSettings.AssemblyInfoFilename)) { string basePath = Path.GetDirectoryName(solutionItem.Filename); return(Common.MakeAbsolutePath(basePath, solutionItem.IncrementSettings.AssemblyInfoFilename)); } string ext = Path.GetExtension(solutionItem.Filename); string filename = "AssemblyInfo"; solutionItem.ProjectType = LanguageType.None; switch (ext) { case ".vbproj": filename += ".vb"; solutionItem.ProjectType = LanguageType.VisualBasic; break; case ".vcproj": filename += ".cpp"; solutionItem.ProjectType = LanguageType.CPPManaged; break; case ".csproj": filename += ".cs"; solutionItem.ProjectType = LanguageType.CSharp; break; case ".sln": Logger.Write("Can't update build version for a solution without specifying an assembly info file.", LogLevel.Error, solutionItem.Filename, 1); return(null); default: Logger.Write("Unknown project file type: \"" + ext + "\"", LogLevel.Error, solutionItem.Filename, 1); return(null); } string ret = null; ProjectItem assemblyInfo = solutionItem.FindProjectItem(filename); if (assemblyInfo == null) { // we couldn't locate the file, but, if it is a C-Project, is also could be an unmanaged project if (ext == ".vcproj") { filename = solutionItem.Name + ".rc"; assemblyInfo = solutionItem.FindProjectItem(filename); solutionItem.ProjectType = LanguageType.CPPUnmanaged; } if (assemblyInfo == null) { Logger.Write("Could not locate \"" + filename + "\" in project.", LogLevel.Warning); return(null); } } ret = assemblyInfo.get_FileNames(0); if (string.IsNullOrEmpty(ret)) { Logger.Write("Located \"" + filename + "\" project item but failed to get filename.", LogLevel.Error); return(null); } Logger.Write("Found \"" + ret + "\"", LogLevel.Debug); return(ret); }