public static IProject LoadProject(IMSBuildEngineProvider provider, string location, string title, string projectTypeGuid, IProgressMonitor progressMonitor) { if (provider == null) throw new ArgumentNullException("provider"); if (location == null) throw new ArgumentNullException("location"); if (title == null) throw new ArgumentNullException("title"); if (projectTypeGuid == null) throw new ArgumentNullException("projectTypeGuid"); if (progressMonitor != null) { progressMonitor.BeginTask("Loading " + title, 0, false); } IProject newProject; if (!File.Exists(location)) { newProject = new MissingProject(location, title); newProject.TypeGuid = projectTypeGuid; } else { ILanguageBinding binding = LanguageBindingService.GetBindingPerProjectFile(location); if (binding != null) { location = FileUtility.NormalizePath(location); try { newProject = binding.LoadProject(provider, location, title); } catch (ProjectLoadException ex) { LoggingService.Warn("Project load error", ex); if (progressMonitor != null) progressMonitor.ShowingDialog = true; newProject = new UnknownProject(location, title, ex.Message, true); newProject.TypeGuid = projectTypeGuid; if (progressMonitor != null) progressMonitor.ShowingDialog = false; } catch (UnauthorizedAccessException ex) { LoggingService.Warn("Project load error", ex); if (progressMonitor != null) progressMonitor.ShowingDialog = true; newProject = new UnknownProject(location, title, ex.Message, true); newProject.TypeGuid = projectTypeGuid; if (progressMonitor != null) progressMonitor.ShowingDialog = false; } } else { string ext = Path.GetExtension(location); if (".proj".Equals(ext, StringComparison.OrdinalIgnoreCase) || ".build".Equals(ext, StringComparison.OrdinalIgnoreCase)) { newProject = new MSBuildFileProject(location, title); newProject.TypeGuid = projectTypeGuid; } else { newProject = new UnknownProject(location, title); newProject.TypeGuid = projectTypeGuid; } } } return newProject; }
public static IProject LoadProject(IMSBuildEngineProvider provider, string location, string title, string projectTypeGuid) { if (provider == null) throw new ArgumentNullException("provider"); if (location == null) throw new ArgumentNullException("location"); if (title == null) throw new ArgumentNullException("title"); if (projectTypeGuid == null) throw new ArgumentNullException("projectTypeGuid"); IProject newProject; if (!File.Exists(location)) { newProject = new MissingProject(location, title); newProject.TypeGuid = projectTypeGuid; } else { ILanguageBinding binding = LanguageBindingService.GetBindingPerProjectFile(location); if (binding != null) { try { location = Path.GetFullPath(location); } catch (Exception) {} try { newProject = binding.LoadProject(provider, location, title); } catch (XmlException ex) { newProject = new UnknownProject(location, title, ex.Message, true); newProject.TypeGuid = projectTypeGuid; } catch (Microsoft.Build.BuildEngine.InvalidProjectFileException ex) { newProject = new UnknownProject(location, title, ex.Message, true); newProject.TypeGuid = projectTypeGuid; } catch (UnauthorizedAccessException ex) { newProject = new UnknownProject(location, title, ex.Message, true); newProject.TypeGuid = projectTypeGuid; } } else { newProject = new UnknownProject(location, title); newProject.TypeGuid = projectTypeGuid; } } return newProject; }
public static IProject LoadProject(ProjectLoadInformation loadInformation) { if (loadInformation == null) throw new ArgumentNullException("loadInformation"); string location = FileUtility.NormalizePath(loadInformation.FileName); string title = loadInformation.ProjectName; IProgressMonitor progressMonitor = loadInformation.ProgressMonitor; progressMonitor.CancellationToken.ThrowIfCancellationRequested(); IProjectBinding binding = ProjectBindingService.GetBindingPerProjectFile(location); IProject newProject; if (!(binding != null && binding.HandlingMissingProject) && !File.Exists(location)) { newProject = new MissingProject(location, title); newProject.TypeGuid = loadInformation.TypeGuid; } else { if (binding != null) { try { newProject = binding.LoadProject(loadInformation); } catch (ProjectLoadException ex) { LoggingService.Warn("Project load error", ex); progressMonitor.ShowingDialog = true; newProject = new UnknownProject(location, title, ex.Message, true); newProject.TypeGuid = loadInformation.TypeGuid; progressMonitor.ShowingDialog = false; } catch (UnauthorizedAccessException ex) { LoggingService.Warn("Project load error", ex); progressMonitor.ShowingDialog = true; newProject = new UnknownProject(location, title, ex.Message, true); newProject.TypeGuid = loadInformation.TypeGuid; progressMonitor.ShowingDialog = false; } } else { string ext = Path.GetExtension(location); if (".proj".Equals(ext, StringComparison.OrdinalIgnoreCase) || ".build".Equals(ext, StringComparison.OrdinalIgnoreCase)) { newProject = new MSBuildFileProject(location, title); newProject.TypeGuid = loadInformation.TypeGuid; } else { newProject = new UnknownProject(location, title); newProject.TypeGuid = loadInformation.TypeGuid; } } } return newProject; }