private static HashSet <string> GetWebsiteLocalAssemblies(EnvDTE.Project envDTEProject) { var assemblies = new HashSet <string>(PathComparer.Default); var references = GetAssemblyReferences(envDTEProject); foreach (AssemblyReference reference in references) { // For websites only include bin assemblies if (reference.ReferencedProject == null && reference.ReferenceKind == AssemblyReferenceType.AssemblyReferenceBin && File.Exists(reference.FullPath)) { assemblies.Add(reference.FullPath); } } // For website projects, we always add .refresh files that point to the corresponding binaries in packages. In the event of bin deployed assemblies that are also GACed, // the ReferenceKind is not AssemblyReferenceBin. Consequently, we work around this by looking for any additional assembly declarations specified via .refresh files. var envDTEProjectPath = envDTEProject.GetFullPath(); CollectionsUtility.AddRange(assemblies, RefreshFileUtility.ResolveRefreshPaths(envDTEProjectPath)); return(assemblies); }
// Get the ProjectItems for a folder path public static async Task <EnvDTE.ProjectItems> GetProjectItemsAsync(EnvDTE.Project envDTEProject, string folderPath, bool createIfNotExists) { ThreadHelper.ThrowIfNotOnUIThread(); if (string.IsNullOrEmpty(folderPath)) { return(envDTEProject.ProjectItems); } // Traverse the path to get at the directory var pathParts = folderPath.Split(PathSeparatorChars, StringSplitOptions.RemoveEmptyEntries); // 'cursor' can contain a reference to either a Project instance or ProjectItem instance. // Both types have the ProjectItems property that we want to access. object cursor = envDTEProject; var fullPath = envDTEProject.GetFullPath(); var folderRelativePath = string.Empty; foreach (var part in pathParts) { fullPath = Path.Combine(fullPath, part); folderRelativePath = Path.Combine(folderRelativePath, part); cursor = await GetOrCreateFolderAsync(envDTEProject, cursor, fullPath, folderRelativePath, part, createIfNotExists); if (cursor == null) { return(null); } } return(GetProjectItems(cursor)); }
private void AddFolderIfNotExist(EnvDTE.Project project, string projectRelativePath) { try { var projectPath = project.GetFullPath(); if (!Directory.Exists(Path.Combine(projectPath, @projectRelativePath))) { AddFolder(project, projectRelativePath); } var pCollection = new ProjectCollection(); var p = pCollection.LoadProject(@project.FullName); p.AddItem("Folder", @projectRelativePath); p.Save(); pCollection.UnloadProject(p); } catch (Exception ex) { throw; } }
private static string GetOutputDir(this EnvDTE.Project vsProject) { return(Path.Combine(vsProject.GetFullPath(), vsProject.GetOutputPath())); }