public void Initialize(IEnumerable <EnvDTEProject> projects, VSNuGetProjectFactory factory) { ThreadHelper.ThrowIfNotOnUIThread(); if (projects.Any()) { foreach (EnvDTEProject project in projects) { try { // If a single project fails this method throws and the rest of the projects will never load AddProject(project, factory); } catch (Exception ex) { // ignore failed projects ActivityLog.LogWarning(ExceptionHelper.LogEntrySource, "The project " + project.Name + " failed to initialize as a nuget project"); ExceptionHelper.WriteToActivityLog(ex); } } // Consider that the cache is initialized, only, when there are any projects to add IsInitialized = true; } }
/// <summary> /// Add a project to the cache. /// </summary> /// <param name="project">project to add to the cache.</param> /// <returns>The project name of the added project.</returns> public EnvDTEProjectName AddProject(EnvDTEProject project, VSNuGetProjectFactory factory) { ThreadHelper.ThrowIfNotOnUIThread(); // Create the nuget project first, if this throws we bail out, and not change the cache var nuGetProject = factory.CreateNuGetProject(project); // First create a project name from the project var EnvDTEProjectName = new EnvDTEProjectName(project); // Do nothing if we already have an entry if (_envDTEProjectCache.ContainsKey(EnvDTEProjectName)) { return(EnvDTEProjectName); } AddShortName(EnvDTEProjectName); _projectNamesCache[EnvDTEProjectName.CustomUniqueName] = EnvDTEProjectName; _projectNamesCache[EnvDTEProjectName.UniqueName] = EnvDTEProjectName; _projectNamesCache[EnvDTEProjectName.FullName] = EnvDTEProjectName; // Add the entry mapping project name to the actual project _envDTEProjectCache[EnvDTEProjectName] = project; _nuGetProjectCache[EnvDTEProjectName] = nuGetProject; return(EnvDTEProjectName); }
private VSNuGetProjectFactory GetProjectFactory() { var settings = ServiceLocator.GetInstance <ISettings>(); // We are doing this to avoid a loop at initialization. We probably want to remove this dependency altogether. var factory = new VSNuGetProjectFactory(() => PackagesFolderPathUtility.GetPackagesFolderPath(this, settings)); return(factory); }
public void Initialize(IEnumerable <Project> projects, VSNuGetProjectFactory factory) { foreach (EnvDTEProject project in projects) { AddProject(project, factory); } IsInitialized = true; }
/// <summary> /// Add a project to the cache. /// </summary> /// <param name="project">project to add to the cache.</param> /// <returns>The project name of the added project.</returns> public EnvDTEProjectName AddProject(EnvDTEProject project, VSNuGetProjectFactory factory) { // First create a project name from the project var EnvDTEProjectName = new EnvDTEProjectName(project); // Do nothing if we already have an entry if (_envDTEProjectCache.ContainsKey(EnvDTEProjectName)) { return(EnvDTEProjectName); } AddShortName(EnvDTEProjectName); _projectNamesCache[EnvDTEProjectName.CustomUniqueName] = EnvDTEProjectName; _projectNamesCache[EnvDTEProjectName.UniqueName] = EnvDTEProjectName; _projectNamesCache[EnvDTEProjectName.FullName] = EnvDTEProjectName; // Add the entry mapping project name to the actual project _envDTEProjectCache[EnvDTEProjectName] = project; _nuGetProjectCache[EnvDTEProjectName] = factory.CreateNuGetProject(project); return(EnvDTEProjectName); }
public static bool SupportsINuGetProjectSystem(EnvDTEProject envDTEProject) { var projectKProject = VSNuGetProjectFactory.GetProjectKProject(envDTEProject); return(projectKProject != null); }